views:

293

answers:

2

I was wondering if there were any dependency injection frameworks for use with development on the iPhone. Being a Java developer by day, I enjoy, and see the benefits of, frameworks like Spring.

You can go part of the way by manually making certain components singletons and tying up the references manually.

A: 

See this very similar, almost-dupe SO post.

In summary, you can achieve similar to DI using Categories. Here's a non-Apple reference.

martin clayton
I'm not sure I see categories as being a form of DI.
lyonanderson
What about a testing category that overrode a method to get a service with a method that returned a mock service instead?
Kendall Helmstetter Gelner
That's a good example. I think maybe I was fixated with the way Spring allows for collaborators to be injected using autowiring. Actually, what you suggest is also a legitimate expression of dependency injection.
lyonanderson
A: 

There is an dependecy injection library for iphone which support autowiring and more nice features http://github.com/mivasi/Objective-IOC

mivasi