Re: initWithCoder but I do not have nib file
Re: initWithCoder but I do not have nib file
- Subject: Re: initWithCoder but I do not have nib file
- From: Luke the Hiesterman <email@hidden>
- Date: Sat, 15 Aug 2009 07:55:22 -0700
What? No, that is not the idea. When an object is unarchived from a
nib it is instantiated as part of the unarchiving process, and you're
supposed to perform initialization in initWithCoder:, not allocation
(that's why in Cocoa we separate the concepts of allocation and
initialization). The code you have below completely negates the effect
of having an object in a nib by creating a new object and returning
that. Instead of returning a new button object, you should be
performing initialization on the one you already have.
Luke
On Aug 15, 2009, at 7:42 AM, Chase Meadors wrote:
The idea is to do something like this in a custom class:
- (id)initWithCoder:(NSCoder *)coder {
if (self = [super initWithCoder:coder]) {
return [NSButton buttonWithType:UIButtonTypeRoundedRect];
}
}
_______________________________________________
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