• 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: variable problem is driving me nuts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variable problem is driving me nuts


  • Subject: Re: variable problem is driving me nuts
  • From: Kyle Sluder <email@hidden>
  • Date: Sun, 28 Oct 2012 12:27:13 -0700

On Oct 28, 2012, at 12:01 PM, Jens Alfke <email@hidden> wrote:

>
> On Oct 28, 2012, at 1:37 AM, Kyle Sluder <email@hidden> wrote:
>
>>> In general, initialization code like this in a nib-loaded object should go into its -awakeFromNib method, which is [almost] guaranteed to be the first method invoked on that object.
>>
>> Actually, the NSTableView docs explicitly warn that this is not the case:
>
> That’s why I said “[almost]”. :)

Well, it's contraindicated enough that I try to never do it.

>
>> Initialize your instance variable in -init, which *is* guaranteed to be the first method called on your object.
>
> I didn’t think init methods were called for objects loaded from nibs? (It’s possible this may have changed over time, though, since the old days when I learned Cocoa coding on the street from Buggsy and Leroy.)

The Resource Programming Guide has the details, but in summary: on OS X, Custom Objects are initialized with -init, Custom Views are initialized with -initWithFrame:, and everything else is initialized with -initWithCoder:.

--Kyle Sluder
_______________________________________________

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


References: 
 >variable problem is driving me nuts (From: H Miersch <email@hidden>)
 >Re: variable problem is driving me nuts (From: Jens Alfke <email@hidden>)
 >Re: variable problem is driving me nuts (From: Kyle Sluder <email@hidden>)
 >Re: variable problem is driving me nuts (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: variable problem is driving me nuts
  • Next by Date: Keeping a menu enabled with a modal dialog running
  • Previous by thread: Re: variable problem is driving me nuts
  • Next by thread: Re: variable problem is driving me nuts
  • Index(es):
    • Date
    • Thread