Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Window setTitle Ignored at Launch?



i'm following hillegass' "view swapping" (chapter 29), concerning the
NSViewController.  i can successfully display the proper view at launch
(based on the index of an NSMutableArray), but i cannot set the window's
title using the same index?  the window loads as "Untitled", which is it's
title in IB.  the window's title only changes when the user chooses a new
view from the popup menu.  what am i doing wrong?

- (void)displayViewController:(ManagingViewController *)vc

{

//Try to end editing

NSWindow *w = [box window];

BOOL ended = [w makeFirstResponder:w];

 if (!ended)

{

NSBeep();

return;

}

 //Put the view in the box

NSView *v = [vc view];

[box setContentView:v];


//-=-=-=-=-=-=-=-=-=-=-=-//

// CHANGE WINDOW'S TITLE //

//-=-=-=-=-=-=-=-=-=-=-=-//


 [w setTitle:[NSString stringWithFormat:@"Application Mode: %@", [vc title
]]];

}

 - (NSString *)windowNibName

{

return @"MyDocument";

}


- (void)windowControllerDidLoadNib:(NSWindowController *)windowController

{

[super windowControllerDidLoadNib:windowController];

NSMenu *menu = [popUp menu];

int i, itemCount;

itemCount = [viewControllers count];

 for (i = 0 ; i < itemCount ; i++)

{

NSViewController *vc = [viewControllers objectAtIndex:i];

NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle:[vc title] action:
@selector(changeViewController:) keyEquivalent:@""];

[mi setTag:i];

[menu addItem:mi];

[mi release];

}

 [self displayViewController:[viewControllers objectAtIndex:0]];

[popUp selectItemAtIndex:0];

}
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.