The helper lib for Objection framework (http://objection-framework.org/).
Define injectable property like, you have
@interface InjectableClassA : NSObject
@end
@interface InjectableClassB : NSObject
@end
@implementation InjectableClassA
objection_register_singleton(InjectableClassA)
@end
@implementation InjectableClassB
@end
@interface ViewController
@InjectSingltonProperty InjectableClassA *classA;
@InjectProperty InjectableClassB *classB;
@end
then the script will auto generate the category like
@implementation ViewController (__Objection__Autogen__)
objection_requires(@"classA",@"classB")
@end
NOTE, @InjectProperty will strong refer to the, and @InjectSingltonProperty will weak refer to the property. You may want to use @InjectSingltonProperty to avoid memory leak in some cases, like the child view controller may inject the context parent view controller (in next section), or a sington and another injectable object refers each other.
When we instantiate singletons in application object graph, they live in memory until the app is destroyed. But there are some singleton dependencies that are useful only when another object is alive. Like child view controllers may depends on parent view controller. Let the parent view controller conforms the
@protocol SOContextViewController <NSObject>
@end
which will create a new injector for the view controller.
Since the new injector inherits from application object graph, you need explictly bind instance or block in module if you still want to define singletons in application object graph.