On Wed, Apr 15, 2009 at 9:03 PM, Jerry Krinock <[email protected]> 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 protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
