XIB を使用して View Controller に挿入されたプロパティを取得できませんinitWithNibName:bundle:
例:
これは私のアセンブリです:
@implementation AppAssembly
- (ViewControllerC *)viewControllerC
{
return [TyphoonDefinition withClass:[ViewControllerC class]
configuration:^(TyphoonDefinition *definition) {
[definition injectProperty:@selector(name) with:@"Injected string"];
}];
}
@end
ViewControllerA コード:
@implementation ViewControllerA
- (IBAction)buttonAction:(id)sender
{
ViewControllerB *viewControllerB = [[ViewControllerB alloc] initWithNibName:@"ViewControllerB" bundle:nil];
[self.navigationController pushViewController:viewControllerB animated:YES];
}
@end
ViewControllerB コード:
@implementation ViewControllerB
- (IBAction)buttonAction:(id)sender
{
ViewControllerC *viewControllerC = [[ViewControllerC alloc] initWithNibName:@"ViewControllerC" bundle:nil];
[self.navigationController pushViewController:viewControllerC animated:YES];
}
@end
ViewControllerC コード:
@interface ViewControllerC : UIViewController
@property (copy, nonatomic) NSString *name;
@end
@implementation ViewControllerC
- (void)viewDidLoad
{
[super viewDidLoad];
// Why is this not being injected?
self.title = self.name;
}
@end
AppDelegate コード:
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
ViewControllerA *rootViewController = [[ViewControllerA alloc] initWithNibName:@"ViewControllerA" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
return YES;
}
@end
私はすでにサンプルをチェックしましたが、それらはこのアプローチとは異なります。私が間違っていることを教えてください。
ありがとう。