• 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: Memory Allocation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Allocation


  • Subject: Re: Memory Allocation
  • From: "Kyle Sluder" <email@hidden>
  • Date: Wed, 16 Jul 2008 14:38:10 -0400

On Wed, Jul 16, 2008 at 2:02 PM, Alexandre Badez
<email@hidden> wrote:
> -(id)init
> {
>    if (![super init])
>        return nil;

You must always assign self to the result of [super init].  If anyone
(*cough* Wil Shipley *cough*) tells you otherwise, they may
inadvertently set you up for some seriously subtle errors.

So the code would be:

- (id)init
{
  if(self = [super init])  // single = is intentional
    NSLog(@"-[%@ init]", [self className]);

  return self;
}

Anyway, your problem is here:

>    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

Why are you doing this?  AppKit creates an autorelease pool for you.

--Kyle Sluder
_______________________________________________

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: Memory Allocation
      • From: "Michael Ash" <email@hidden>
    • Re: Memory Allocation
      • From: "Alexandre Badez" <email@hidden>
References: 
 >Memory Allocation (From: "Alexandre Badez" <email@hidden>)

  • Prev by Date: CALayer glitch: move one sublayer, add/remove another
  • Next by Date: Re: Handling key equivalents in a controller class?
  • Previous by thread: Memory Allocation
  • Next by thread: Re: Memory Allocation
  • Index(es):
    • Date
    • Thread