I am programming a Cocoa application and want the application to work as a kind of wizard. Therefore, in the main window, I have a user view that interacts with the user and changes sign on the device’s activation screen when they go through the steps of the wizard. I am currently overriding the wakeFromNib WizardViewController method:
- (void)awakeFromNib{ //If no redirect request save, add first view: ID Login NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSString *tokenRequest = [defaults objectForKey:@"redirectRequestToken"]; if (!tokenRequest){ SignInWithIDViewController *signInViewController = [[SignInWithIDViewController alloc] initWithNibName:@"SignInWithIDViewController" bundle:nil]; [wizardView addSubview:[signInViewController view]]; } else { NSLog(@"Have already logged in."); } }
As is, the initWithNibName in the SignInIDViewController is called twice, once explicitly, and again when the view is loaded (presumably via loadView). However, if I just call init, then the name initWithNib is called only once, but the wrong xib file is loaded (class DeviceActivationViewController). I cannot understand what I'm doing wrong, because signInViewController does not have to be initialized twice, but I need the corresponding xib file in IB to display.
The only other method that I have in this class at this time that is not a user interface. IBAction is the generated initWithNibName method plus the added NSLog statement.
cocoa xib nsviewcontroller init
Katie May 31 '12 at 13:51 2012-05-31 13:51
source share