问题描述
任何人都可以为iOS推荐一个好的IoC框架来方便依赖注入?
Can anyone recommend a good IoC framework for iOS to facilitate dependency injection?
目前我发现的唯一一个是,显然与Guice类似(不幸的是我不熟悉)。这是iOS的常见选择,还有值得一试的竞争框架?
The only one I've found so far is Objection Framework which apparently is similar to Guice (which unfortunately is unfamiliar to me). Is this one a common choice for iOS and are there competing frameworks that are worth checking out?
推荐答案
是我可以在google上找到iOS的DI库,所以如果你想要一个预建的库,你可能会被困住。
Objection is the DI library I could find on google for iOS, so you might be stuck with it if you want a pre-built library.
DI不具体要求使用框架。如果您的应用程序很小,您可以在应用程序根目录下创建所有实例,然后手动注入。
DI doesn't specifically require a framework to use. If your app is small, you can simply create all your instances at the application root and inject by hand.
如果您需要更多的内容,而现有的框架是您可以自己剪切自己的服务定位器,然后在其上构建一个DI容器。
If you need more than this, and the existing frameworks aren't cutting it for you, you could roll your own Service Locator, then build a DI container on top of it.
您还可以从另一个平台移植现有的较小的框架。例如.Net上有几个小的 - 和。
You could also port an existing smaller framework from another platform. There are several "small" ones on .Net, for example - Ninject and SimpleInjector.
似乎这是一个相当小的项目,因为只列出一个作者/贡献者。没有很多问题提交。 iOS市场虽然相当大,所以我认为只有极少部分的iOS开发人员使用这个库。
It seems that it is a fairly small project as there is only one author/contributor listed. There aren't many issues filed. The iOS market is fairly large though. So I'm thinking that only a very small portion of all iOS developers use this library.
但这不一定是坏事。似乎是。 。
But this isn't necessarily a bad thing. It seems to be created, used, and supported by a small company. It has had fairly steady updates for the past year.
我的类似范围的开源项目的传奇经验:我并不总是经常得到新功能,而且我经常是最终发现错误的人。但是,我倾向于很快获得对现有功能集的支持,并且非常重视支持我发送的电子邮件。 YMMV。
My anecdotal experience with similarly scoped open source projects: I don't always get new features super-often, and I'm often the one who ends up finding bugs. But I tend to get support on the existing feature set very quickly, and a lot of attention is paid to support e-mails I've sent. YMMV.
这篇关于iOS推荐的IoC框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!