Mysterious crash in loaded nib
Mysterious crash in loaded nib
- Subject: Mysterious crash in loaded nib
- From: Andrew Merenbach <email@hidden>
- Date: Mon, 20 Aug 2007 09:03:35 -0700
Hi, all,
I have a nib that I load with:
- (id)init {
if (nil != (self = [super init])) {
if (![NSBundle loadNibNamed:@"SearchController" owner:self]) {
[self release];
self = nil;
}
}
return self;
}
and it works beautifully--except for two items, a text field and a
popup button. These items are added to a toolbar, whose delegate
belongs to a different class, so I use cover accessors to gain access
to these interface items. Here's an example of one of my accessors:
- (PTextField *)toolbarSearchField {
return search_field;
}
I have also tried "return [[searchField retain] autorelease];".
I use the following code to add one of the items to my toolbar (it's
the same for the other item in terms of layout):
id toolbarSearchField = [search toolbarSearchField];
[toolbarSearchField retain];
[toolbarSearchField removeFromSuperview];
[item setView:toolbarSearchField];
[toolbarSearchField release];
I am getting various crashes--one related to EXC_BAD_ACCESS, and
another time NSLock was receiving the message--all on the "-retain"
line in the code directly above. It is clear that my search_field is
getting deallocated before I can use it.
But how? My toolbar items are located in a top-level view in my nib
file--a view with an IBOutlet connected directly to it. My
understanding is that +loadNibNamed:owner: *retains* top-level
objects. How could my search_field get dealloc'ed before I get the
chance to use it?
Cheers,
Andrew
_______________________________________________
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