AppleGuice
AppleGuice copied to clipboard
Can't inject to UIViewController that is initialized with a storyboard
dependencies inside a UIViewController that is initialized with a storyboard are always null. The reason for that is that VCs that are created this way (not with [[UIViewController alloc] init]
) never call init since they use initWithCoder:
instead.
A tmp workaround is to add the following to a UIViewController that is used with storyboards.
-(instancetype)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[AppleGuice injectImplementationsToInstance:self];
}
return self;
}