• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: initWithCoder but I do not have nib file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: initWithCoder but I do not have nib file
      • From: Chase Meadors <email@hidden>
References: 
 >initWithCoder but I do not have nib file (From: Agha Khan <email@hidden>)
 >Re: initWithCoder but I do not have nib file (From: Chase Meadors <email@hidden>)

  • Prev by Date: Re: initWithCoder but I do not have nib file
  • Next by Date: Re: initWithCoder but I do not have nib file
  • Previous by thread: Re: initWithCoder but I do not have nib file
  • Next by thread: Re: initWithCoder but I do not have nib file
  • Index(es):
    • Date
    • Thread