NSWindowDidBecomeMainNotification firing twice?
NSWindowDidBecomeMainNotification firing twice?
- Subject: NSWindowDidBecomeMainNotification firing twice?
- From: James McConnell <email@hidden>
- Date: Sun, 07 Mar 2004 13:03:32 -0600
In my application, I have a need to track which document is currently the
"main" document. I have set up the correct notifications and it seems to be
firing twice.
This is the code I have in - (void)awakeFromNib: in MyDocument
<start code>
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(postWindowBecameMain:)
name:NSWindowDidBecomeMainNotification object:nil];
<end code>
Then, my postWindowBecameMain: method looks like this
<start code>
- (void)postWindowBecameMain:(NSNotification*)notification
{
NSLog(@"%@ Window Became Main", [self displayName]);
}
<end code>
Fairly simple. When a document window becomes active, it simply prints it's
name to the console. I'll be using this method to pass document data, but I
don't want to implement that until I get this figured out. After starting
the app and creating one new document window, the console output looks like
this:
2004-03-07 13:01:23.045 XRecipeManager[14231] Untitled Window Became Main
2004-03-07 13:01:25.212 XRecipeManager[14231] Untitled Window Became Main
2004-03-07 13:01:25.214 XRecipeManager[14231] Untitled 2 Window Became Main
Switching back to the original window gives me this output:
2004-03-07 13:01:23.045 XRecipeManager[14231] Untitled Window Became Main
2004-03-07 13:01:25.212 XRecipeManager[14231] Untitled Window Became Main
2004-03-07 13:01:25.214 XRecipeManager[14231] Untitled 2 Window Became Main
2004-03-07 13:02:14.012 XRecipeManager[14231] Untitled Window Became Main
2004-03-07 13:02:14.012 XRecipeManager[14231] Untitled 2 Window Became Main
So every time the window is the "main" window, it displays both window
names. All I want it to do is to display the window that is "main", not
both. Any suggestions? Thanks again for the help on the delegate issue.
All has been resolved.
James
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.