Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Foo new] vs [[Foo alloc] init]:



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: [Foo new] vs [[Foo alloc] init]: (From: Gregory Weston <email@hidden>)
 >Re: [Foo new] vs [[Foo alloc] init]: (From: Bill Bumgarner <email@hidden>)
 >Re: [Foo new] vs [[Foo alloc] init]: (From: Gregory Weston <email@hidden>)
 >Re: [Foo new] vs [[Foo alloc] init]: (From: Bill Bumgarner <email@hidden>)
 >Re: [Foo new] vs [[Foo alloc] init]: (From: Gregory Weston <email@hidden>)
 >Re: [Foo new] vs [[Foo alloc] init]: (From: Bill Bumgarner <email@hidden>)
 >Re: [Foo new] vs [[Foo alloc] init]: (From: Gregory Weston <email@hidden>)
 >Re: [Foo new] vs [[Foo alloc] init]: (From: Bill Bumgarner <email@hidden>)
 >Re: [Foo new] vs [[Foo alloc] init]: (From: Gregory Weston <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.