Cocoa的依赖注入框架? [英] Dependency injection framework for Cocoa?

查看:132
本文介绍了Cocoa的依赖注入框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Interface Builder可以用于Cocoa应用程序中的基本依赖注入,但是当你不想在NIB文件中实例化对象时,是否有人知道Objective-C / Cocoa有更完整的依赖注入框架? p>

编辑



为了说明,我认为IB可用于基本DI,但我正在寻找一个具有更完整功能的框架,包括单独的生产和测试配置,沿着Groovy或Springs。

解决方案

我想你会发现,你不需要它在后期绑定的语言,如Objective C,Ruby,Lisp等。像Jamis的启示,当他试图建立针,一个DI框架的Ruby-下一个过于复杂的路径 - Net :: SSH revisited



这里有一些链接,希望能给你一些示例代码做类似的事物在Objective C.有了类别,你可以在本质上改变任何类的行为在运行时。请参见 Mac开发人员提示 - 目标C:类别 Cocoa API文档的类别。基本上你不需要一些中心的地方来要求可以配置的事情,因为你可以直接实例化TheThingThatDoesX,如果别的东西需要改变/钩到那个行为,它可以使用类别。


Interface Builder can be used for basic dependency injection in a Cocoa app, but is anyone aware of more complete dependency injection frameworks for Objective-C/Cocoa for when you don't want to instantiate objects in a NIB file?

Edit

To clarify, I recognize that IB can be used for basic DI, but I'm looking for a framework with more complete functionality, including separate production and testing configurations, along the lines of Groovy or Springs.

解决方案

I think you'll find that you don't need it in late-binding languages like Objective C, Ruby, Lisp and so on. Like Jamis' revelation that he was going down an overly complex path when he tried to build needle, a DI framework for Ruby- Net::SSH revisited.

Here are some links that will hopefully give you some sample code to do similar things in Objective C. With categories you can essentially change any class's behavior at runtime. See Mac Developer Tips – Objective-C: Categories and the Cocoa API docs on categories. Essentially you don't need some central place to ask for "the thing that does x" that is configurable, because you can just instantiate TheThingThatDoesX directly and if something else needs to change/hook into that behavior it can use categories.

这篇关于Cocoa的依赖注入框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆