• 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: Stack-based C++ class to wrap NSAutoreleasePool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stack-based C++ class to wrap NSAutoreleasePool


  • Subject: Re: Stack-based C++ class to wrap NSAutoreleasePool
  • From: BJ Homer <email@hidden>
  • Date: Mon, 16 Nov 2009 12:28:21 -0700

Does the stack-based idiom allow returning an autoreleased object?  I'd
think you'd end up with code like this:

- (id)arrayWithStuff {
  StackAutoreleasePool();
  NSArray *array = [NSArray arrayWithObjects:obj1, obj2, etc, nil];
  return array;
}

which would essentially translate into:

- (id)arrayWithStuff {
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  NSArray *array = [NSArray arrayWithObjects:obj1, obj2, etc, nil];
  [pool release];
  return array;  // array is dead
}

Is there some reason why this would not happen?

-BJ
_______________________________________________

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: Stack-based C++ class to wrap NSAutoreleasePool
      • From: Clark Cox <email@hidden>
References: 
 >Stack-based C++ class to wrap NSAutoreleasePool (From: Dan Korn <email@hidden>)
 >Re: Stack-based C++ class to wrap NSAutoreleasePool (From: Clark Cox <email@hidden>)
 >Re: Stack-based C++ class to wrap NSAutoreleasePool (From: Kyle Sluder <email@hidden>)
 >Re: Stack-based C++ class to wrap NSAutoreleasePool (From: Clark Cox <email@hidden>)

  • Prev by Date: Re: opening a document via Finder without NSDocument
  • Next by Date: Re: opening a document via Finder without NSDocument SOLVED
  • Previous by thread: Re: Stack-based C++ class to wrap NSAutoreleasePool
  • Next by thread: Re: Stack-based C++ class to wrap NSAutoreleasePool
  • Index(es):
    • Date
    • Thread