Re: NSView initWithFrame called twice
Re: NSView initWithFrame called twice
- Subject: Re: NSView initWithFrame called twice
- From: Brian Webster <email@hidden>
- Date: Mon, 12 Aug 2002 08:57:18 -0500
It looks like there are two instances of your view in your nib
file for some reason. The debugger marks variables that change
between breaks in red, so since you broke on that method twice
in a row with two different values of self, it marked it in red
to show that it changed.
You might want to look at your nib using the outline view (click
on the little widget above the scrollbar in the instances tab)
to double check the exact contents of the nib. I've had a
couple cases where I had two views directly overlapped on one
another and couldn't see it in the window, but they show up in
the outline view.
Also, your initWithFrame: method should return self at the end.
On Monday, August 12, 2002, at 02:17 AM, Albert Russel wrote:
I did look at the stack trace before I posted my question but
it is the same
for both calls:
0 -[MyView initWithFrame:]
1 -[NSCustomView nibInstantiate:]
2 -[NSCustomView nibInstantiate:]
3 -[NSIBObjectData instantiateObject:]
4 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:]
5 -[NSRTFReader dealloc]
6 +[NSBundle(NSNibLoading)_loadNibFile:name
Table:withZone:ownerBur....
7 +[NSBundle(NSNibLoading)_loadNibFile:externalName Table:withZone:]
8 +[NSBundle(NSNibLoading) LoadNibNamed:owner:]
9 NSApplicationMain
10 main
11 _start
12 start
The value for self is different for the 2 calls though and the
value of self
in the second call is shown in red instead of black. Why this
red color and
does this mean there are 2 MyViews in the nib file? I can only
see 1 MyView
in InterfaceBuilder.
I stripped the init to this:
- (id) initWithFrame: (NSRect) rect
{
[super initWithFrame: rect];
NSLog(@"init gets called\n");
}
Set a breakpoint in the initWithFrame: method and run it using
the debugger. This will let you see the stack trace where each
call is made. Also, check to see if the method is being called
twice on the same object, or if there are actually two different
objects each being sent the message once.
On Sunday, August 11, 2002, at 02:20 PM, cocoa-dev-
email@hidden wrote:
I have a NSView derived custom view within an NSScrollView. It
has the
following initialization method:
- (id) initWithFrame:(NSRect) frameRect
When my program starts the initWithFrame method gets called twice. I
understand that when the nib file is unarchived one init
message is sent to
my custom view but where does the second message come from? Is
it sent from
the NSScrollView and if so how do I prevent this from happening.
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.