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 08:58:49 -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 one of my accessors:
- (PTextField *)toolbarSearchField {
return search_field;
}
I have also tried using "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];
Somehow, I'm getting crashes on the -retain call! Once it was an
EXC_BAD_ACCESS, and another time NSLock was receiving the message.
It is of course clear that my control is getting released before I
get the chance to use it.
But how? These toolbar items are located within a top-level NSView
in my nib file--and I have an IBOutlet set to this NSView, so (if
previous postings are correct--and also if my experiences with -
+loadNibNamed:owner: lead me to the correct conclusion)--the top-
level items should be retained automatically.
Does anyone have any inkling as to what's going on?
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