Oxen (aka "the offshore guys") published an Apache 2.0 open source IoC container for Cocoa/iPhone.
IoC Container description
The IoC container provides dependency injection to Cocoa applications. It was created with iPhone development in mind.
It aims to provide some functionalities from Spring and from Guice (in fact, we're somehow inspired by RoboGuice). But due to the complexity inherent to implementing a full IoC container (as the ones mentioned before), we restricted it to very basic features.
The container has the following characteristics:
- The container holds definitions about objects. No object is created until somebody request it.
- Every definition must have a name that must be unique inside the container in order to identify the object.
- The definition can indicate that the object must be singleton (it is created and stored in a pool when the object is requested the first time). If singleton is specified as FALSE, the object will be created each time (but it can be released when no longer required). This is similar to prototype scope in Spring , an as we learned from using RoboGuice, this behavior would be preferible in many mobile development scenarios.
- The definition can indicate that the object must lazy. That is, when the object is requested, a proxy to such object is returned. Upon the first method call on such reference, the object is created. This is useful for avoiding creating big object graphs unnecessarily.
- The object can be injected (this is the main goal of the framework!). It must have properties or at least setters for performing the injection. The definition allows performing the following injections:
- References to other definitions (by name).
- New factories can be implemented for object creation customization.
- Container instantiation can be done by code and "annotations" (like Guice/Spring) or by XML (like Spring).
Read more at: