Re: MORE: Setting hierarchy of NIB items
Re: MORE: Setting hierarchy of NIB items
- Subject: Re: MORE: Setting hierarchy of NIB items
- From: "Louis C. Sacha" <email@hidden>
- Date: Tue, 17 Feb 2004 17:16:15 -0800
Hello...
I'm not really sure what is happening based on your description, but
just to clarify, if you have an NSLog statement in the awakeFromNib
method it should be triggered three times if you have three instances
in the nib, once for each instance.
Just a general suggestion, since maybe it will help you debug, if you
are not doing something similar already:
If you include the result of [self hash] in an NSLog statement, it
can help you to identify which instance is using that particular
method at that time. For example adding the following line to your
awake from nib method,
NSLog(@"QDView -- starting awakeFromNib - %u",[self hash]);
When the NSLog statement is output, it will include the hash value of
the object that was sent the awakeFromNib message. Since you have
three QDView instances in your nib, you should get three of these
messages, with a different hash value each time. Any log output for
messages sent to the same instance will always have the same hash
value. If you add a similar NSLog statement (using [self hash]) to
another method, you can track which particular instance is recieving
the message.
You can also use this to identify a particular instance in a "human
readable" way, for example in your controller class's awakeFromNib
you could add something like this using your outlets:
/* myQDView is an outlet in your controller that is connected
to one of the QDView instances */
if (myQDView) {NSLog(@"myQDView is %u",[myQDView hash]);}
else {NSLog(@"myQDView is nil");}
Using hash this way doesn't work with objects like NSStrings that are
"value" type objects (since hash is defined differently in terms of
the value/string equality), but it works well for views, controls,
cells, your custom classes that are simple subclasses of NSObject,
etc... ***
Hope that helps you to figure it out, if you haven't already...
Louis
***It's possible you could also just use self as one of the arguments
and output it in the NSLog statement, but at the moment I can't
remember if NSLog uses the %p syntax, and can't check right now.
NSLog(@"QDView -- starting awakeFromNib - %p",self);
I just use [self hash] in most situations anyway, since in the cases
where hash doesn't work, you usually would just ouput the value of
the object in the NSLog statement instead.
It appears that 'awakeFromNIB' in my NSQuickDrawView subclasss
QDView is getting called twice when my app starts up. The first
time it's called, all the NSButtons items in my object are set to
non-null values and the second time it is called, the items are all
NULL. When the 'drawRect' function is called, the SECOND 'self' is
making the call - the one with the NULL NSButton references.
There are THREE QDViews in the NIB - only two have Actions or Outlets.
Does this tell you anything - if so, please tell ME!
Thanks very much,
Lance Drake
_______________________________________________
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.