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: Chase Meadors <email@hidden>
- Date: Sat, 15 Aug 2009 10:14:34 -0500
You're completely correct, that was an error on my part. I don't know
exactly why I wrote it that way... morning?
On Aug 15, 2009, at 9:55 AM, Luke the Hiesterman wrote:
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