I want to thank Fritz, Greg, Quincy and Uli for their help solving
this problem. I don't think there is any general solution to this
problem, but I wanted to make two remarks that might help others who
run into something similar.
(i) It turned out that i did have two different MyDocument o
On 09.06.2009, at 17:48, Greg Guerin wrote:
How do you know -init is only run once?
Are you sure no other init method is run? Like maybe initWithCoder:?
As a general rule, when you wonder where an object is coming from,
it helps to have a look at any and all -init methods the class has. I
K. Darcy Otto wrote:
@interface MyDocument : NSDocument
{
BOOL sheetOpen; // sheetOpen must be accessed directly; there are
no accessors
... other stuff ...
}
I hate to give the bad news, but sheetOpen is an instance variable of
MyDocument, not a class variable or static variable.
The
On Jun 9, 2009, at 15:50, K. Darcy Otto wrote:
Bizarreness at **! I mean, -init is only run once!
Your first and *only* concern at this point is to work out why you
have 2 document objects. As a preliminary to that, you need to stop
thinking of the extra document object as a magical manif
You're right, my two questions are related. I do, ultimately, want to
tell if a panel is open. The reason I want to know whether the panel
is open, is that I want to disable certain menu options via -
validateUserInterfaceItem while that panel is open. The panel is a
sheet that comes down
Hi Greg,
Thanks for your suggestions. I got some (to me) surprising results.
Here is the code:
Code
From MyDocument.h:
@interface MyDocument : NSDocument
{
BOOL sheetOpen; // sheetOpen must be accessed directly; there are no
accessors
... other stuff .
K. Darcy Otto wrote:
-(void)windowWillBeginSheet:(NSNotification *)notification
{
sheetOpen = YES;
NSLog(@"self at -windowWillBeginSheet: %@",self);
}
I would NSLog the before and after state of sheetOpen, i.e. on entry
to the method body and on exit from the method body. I
Okay, so if I'm seeing two different objects, I guess the question is,
where is the second object being created? I had a look an my .xib:
the File's Owner is of type "MyDocument"; but there appear to be no
places where I instantiate a MyDocument object. I put an NSLog into
the -init of My
On 8 Jun 2009, at 10:02 PM, K. Darcy Otto wrote:
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 * (