• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSApp and main window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSApp and main window


  • Subject: NSApp and main window
  • From: Coleman Nitroy <email@hidden>
  • Date: Sat, 1 Jan 2005 15:14:11 -0500

I am working on loading data from a file and putting it all into a data model class. So far all works well until I try to get it to work with the multiple document format. I have two questions:

How do I make like the "new file" stuff. For example, when I load a existing file in, MyDocument handles loading of the data and creates the instance of the model data object, then fills it with the proper values and such, how do I say "when starting a new document create a instance of the model data object and fill it with this..."

Question two is a bit more involved (I think)

How do I properly get panels to update based on the main document window selected. I have gotten this far on my own.
I have a custom view that the MyDocument loads in replace of its normal stuff like this:


- (void) makeWindowControllers
{
windowController = [[ATMapViewController alloc] initWithWindowNibName:@"ATWindow"];
[self addWindowController:windowController];
}


Then I have a Controller for a particular panel I want to have updated. This code has some notifications in it for when the main window has changed, they all work fine, but for some reason, even though I am running setMainWindow with every new main window change the model data object instance always displays the same stuff, which is that its completely empty, even though i am pulling it thru the custom view class.

- (void)setMainWindow:(NSWindow *)mainWindow {
    NSWindowController *controller = [mainWindow windowController];

if (controller && [controller isKindOfClass:[ATMapViewController class]]) {
currentMap = [(ATMapViewController *)controller currentMap];
} else {
currentMap = nil;
}
needsUpdate = YES;
}


- (void)windowDidLoad {
[super windowDidLoad];
[self setMainWindow:[NSApp mainWindow]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainWindowChanged:) name:NSWindowDidBecomeMainNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainWindowResigned:) name:NSWindowDidResignMainNotification object:nil];
}


- (void)mainWindowChanged:(NSNotification *)notification {
    NSLog(@"%@", [notification object]);
    [self setMainWindow:[notification object]];
    [self setValues];
    NSLog(@"Main Window Changed");
}

- (void)mainWindowResigned:(NSNotification *)notification {
    [self setMainWindow:nil];
    NSLog(@"Main Window Resigned");
}

- (void)windowDidUpdate:(NSNotification *)notification {
    if (needsUpdate) {
	NSLog(@"We need updating");
        needsUpdate = NO;
	[self setValues];
    }
}

Thanks for any input.

---
Coleman Nitroy
email@hidden
nitroy.com/cole

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: storing, searching, and displaying variable-sized data sets
  • Next by Date: Re: Accurate decimal numbers?
  • Previous by thread: Re: storing, searching, and displaying variable-sized data sets
  • Next by thread: Re: NSApp and main window
  • Index(es):
    • Date
    • Thread