Thanks, Andy. Excellent point.

Seems to me I remember reading that... now!

After always checking for nil allocation and error codes on various systems (my style since '78) and reinforced by MacOS toolbox procedural programming from '83, it is hard to write what looks like trusting code.

It is easier to write, however, so I'll get there!

Apologies for the noise.

MP
(learning to chill out)

On Jun 17, 2009, at 4:37 AM, Andy Lee wrote:

On Jun 17, 2009, at 6:29 AM, M Pulis wrote:
Most of us see the alloc init pattern when learning from example code for a quick feature demo. For purposes of brevity, example code is never meant to demonstrate error handling, much like I don't expect to see MyClass in shipping source.

The reason for the alloc/init idiom is to avoid this easy-to-make mistake:

    MyClass *myObject = [MyClass alloc];
    [myObject init];

I don't mean this as an answer to the larger question about nil- messaging, but to point out that this is an explicitly recommended idiom, not just a way for the authors of the examples to save a few keystrokes.

--Andy

_______________________________________________

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]

Reply via email to