• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Foo new] vs [[Foo alloc] init]:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: [Foo new] vs [[Foo alloc] init]:
      • From: Gregory Weston <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>)

  • Prev by Date: Re: Best way to replace one view with another within a superview
  • Next by Date: Re: [Foo new] vs [[Foo alloc] init]:
  • Previous by thread: Re: [Foo new] vs [[Foo alloc] init]:
  • Next by thread: Re: [Foo new] vs [[Foo alloc] init]:
  • Index(es):
    • Date
    • Thread