Re: [Foo new] vs [[Foo alloc] init]:
Re: [Foo new] vs [[Foo alloc] init]:
- Subject: Re: [Foo new] vs [[Foo alloc] init]:
- From: j o a r <email@hidden>
- Date: Sun, 17 Feb 2008 16:47:17 -0800
On Feb 17, 2008, at 2:28 PM, Gregory Weston wrote:
+alloc is a cover for +allocWithZone: with a NULL zone. Not that
you would know that from the documentation, unfortunately.
Which means, like the current behavior of new, that's an
implementation detail that shouldn't really be relied on.
I can't see why this would ever matter much in practice, but if you're
concerned about the API promise (or lack thereof) for "+new", why not
fix it by either adding an implementation that you approve of, and
that you can control, as a category to NSObject, or as a macro?
@implementation NSObject (BetterNew)
+ (id) betterNew { return [[self alloc] init]; }
@end
Problem solved, and as an additional bonus we won't have to suffer any
more messages about this on the list...
j o a r
_______________________________________________
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