Re: [Foo new] vs [[Foo alloc] init]:
Re: [Foo new] vs [[Foo alloc] init]:
- Subject: Re: [Foo new] vs [[Foo alloc] init]:
- From: "Hamish Allan" <email@hidden>
- Date: Sun, 17 Feb 2008 23:47:29 +0000
On Feb 17, 2008 7:15 PM, Gregory Weston <email@hidden> wrote:
> See what you're saying? +alloc *or* +allocWithZone:.
>
> See the subject? +alloc. It does not say anything about +allocWithZone:.
>
> See this code?
>
> [...]
>
> Guess how many times it emits "allocating" on 10.4. Hint: It's not
> the same as 10.5.
Your argument would be somewhat stronger if your code looked like this:
@implementation MyTest
+ (id)allocWithZone:(NSZone *z)
{
if (z && z != NSDefaultMallocZone())
NSLog(@"allocating in some way not equivalent to calling plain alloc");
return [super allocWithZone:z];
}
@end
In other words, +new may not call +alloc, but if it calls
+allocWithZone: with exactly the same effect, the point is moot. You
might think of +allocWithZone: as being the "designated allocator"
(pre-Leopard, at least) -- you would always override that rather than
+alloc.
Hamish
_______________________________________________
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