self Changes on Open Panel
self Changes on Open Panel
- Subject: self Changes on Open Panel
- From: "K. Darcy Otto" <email@hidden>
- Date: Mon, 8 Jun 2009 22:02:37 -0700
I'm having some problems pinning down what is going on when I open a
panel: object variables seem to get reset somehow, and "self" seems to
change. Here is some code, from my NSDocument subclass (MyDocument):
-(void)windowWillBeginSheet:(NSNotification *)notification
{
sheetOpen = YES;
NSLog(@"self at -windowWillBeginSheet: %@",self);
}
-(BOOL)validateUserInterfaceItem:(id
<NSValidatedUserInterfaceItem>)anItem
{
if (sheetOpen) NSLog(@"sheetOpen = YES");
else NSLog(@"sheetOpen = NO");
NSLog(@"self at -validateUserInterfaceItem: %@",self);
... and validation code
}
And here is the output - with the exception of *:
sheetOpen = NO
self at -validateUserInterfaceItem: <MyDocument: 0x1036290>
self at -windowWillBeginSheet: <MyDocument: 0x1036290>
*
sheetOpen = NO
self at -validateUserInterfaceItem: <MyDocument: 0x102d8f0>
The sheet opens at *. Two questions: (i) why is MyDocument at a
different address before and after * (incidentally, it changes back to
0x1036290 after the sheet has closed)? (ii) Why is sheetOpen (which is
a class variable) not YES after * (in fact, under no circumstances
does it return a YES, before, during or after the sheet)?
Very puzzling. I can't help but think (i) and (ii) are interconnected
in some way (different object implies different object variables), but
I can't put my finger on it. Any insights would be appreciated.
_______________________________________________
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:
This email sent to email@hidden