Reputation: 33140
BGLogin * login = [[BGLogin alloc]init];
[nav pushViewController:login animated:YES];
login.view; //access it once to trigger didload
NSAssert(login.navigationItem==login.navigationItemAtDidload,@"They should be the same");//View didload isn't called yet here.
NSAssert(login.navigationController == nav,@"The navigation controller should be the same");
NSAssert(nav.navigationBar.topItem==login.navigationItem,@"We just push our self so our stuff should be on top");
It's simple code. However if I do not do login.view then viewDidLoad will not be called first. If I do login.view than I got a warning that value of login.view is not used.
So what should I do?
Upvotes: 0
Views: 93
Reputation: 21289
If you don't care about the return value, then don't use the property accessor syntax (login.view
). Call the getter like a regular method: [login view]
.
Upvotes: 2
Reputation: 4731
If you just want use login.view;
to make the viewDidLoad
be called , I think you had better to add some code in your BGLogin
classs init
method.
such as :
- (id)init
{
// your code
self.view.tag = 0;
return self;
}
or you can change your login.view;
to login.view.tag = 0;
it will call the viewDidLoad
, but I do not think it is better , but it will work for you , maybe somebody has a better way to handle it
Upvotes: 1