Skip to content

Instantly share code, notes, and snippets.

@shawn42
Created December 8, 2010 20:43
Show Gist options
  • Save shawn42/733887 to your computer and use it in GitHub Desktop.
Save shawn42/733887 to your computer and use it in GitHub Desktop.
Example
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
ObjectionInjector *injector = [Objection createInjector];
[Objection setGlobalInjector:injector];
}
- (void)viewDidLoad {
id myModel = [[Objection globalInjector] getObject:[MyModel class]];
}
@class Engine, Brakes;
@interface Car : NSObject
{
Engine *engine;
Brakes *brakes;
BOOL awake;
}
// Will be filled in by objection
@property(nonatomic, retain) Engine *engine;
// Will be filled in by objection
@property(nonatomic, retain) Brakes *brakes;
@property(nonatomic) BOOL awake;
@implementation Car
objection_register(Car)
objection_requires(@"engine", @"brakes")
@synthesize engine, brakes, awake;
@end
- (void)someMethod {
ObjectionInjector *injector = [Objection createInjector];
id car = [injector getObject:[Car class]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment