• 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: Apple's PredicateEditorSample returns [self init] in -awakeFromNib ?!?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apple's PredicateEditorSample returns [self init] in -awakeFromNib ?!?


  • Subject: Re: Apple's PredicateEditorSample returns [self init] in -awakeFromNib ?!?
  • From: Michael Ash <email@hidden>
  • Date: Thu, 16 Apr 2009 01:07:16 -0400

On Wed, Apr 15, 2009 at 9:03 PM, Jerry Krinock <email@hidden> wrote:
> I just noticed that in Apple's PredicateEditorSample, the window
> controller's -awakeFromNib returns [self init]...
>
>
> - (id)awakeFromNib {
>    ...
>    ...
>    return [self init] ;
> }
>
> Here's the whole source:
>
>   http://developer.apple.com/samplecode/PredicateEditorSample/listing5.html
>
> I see no explanation of this in -awakeFromNib documentation.  Yet, this
> project actually seems to work.  What in the world are they doing in there?

It's completely busted. It works only by coincidence, relying on two things:

1) awakeFromNib is supposed to return void, but calling conventions
for void return functions are the same as for pointer return functions
on all platforms OS X currently runs on, so there is no conflict. The
caller will just ignore the returned value.

2) The -init method either does nothing, does something but is
harmless the second time around, or is harmful but in some non-obvious
way, like leaking memory.

File a bug, and by no means imitate this broken code.

MIke
_______________________________________________

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: Apple's PredicateEditorSample returns [self init] in -awakeFromNib ?!?
      • From: Jerry Krinock <email@hidden>
References: 
 >Apple's PredicateEditorSample returns [self init] in -awakeFromNib ?!? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: NSOpenGLView and antialiasing
  • Next by Date: Re: -viewDidMoveToWindow without subclassing? NSViewController?
  • Previous by thread: Apple's PredicateEditorSample returns [self init] in -awakeFromNib ?!?
  • Next by thread: Re: Apple's PredicateEditorSample returns [self init] in -awakeFromNib ?!?
  • Index(es):
    • Date
    • Thread