• 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: Fast Enumeration and temporary objects/autoreleasing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fast Enumeration and temporary objects/autoreleasing


  • Subject: Re: Fast Enumeration and temporary objects/autoreleasing
  • From: Roland King <email@hidden>
  • Date: Mon, 16 Apr 2012 17:53:59 +0800

There are no temporary objects created during fast enumeration, you just get a reference to one of the objects in the thing you are enumerating.

[ array objectAtIndex:i ] doesn't create temporaries either.


On Apr 16, 2012, at 5:42 PM, Patrick Robertson wrote:

> Hi all,
>
> I've searched the web, but can't seem to find any concrete information on
> how fast enumeration loops manage temporarily created objects.
> Would anybody be able to shine some light on whether fast enumeration
> itself takes care of the objects it creates?
>
> So, for example in:
>
> for (id anObject in anArray) {
> // do some stuff
> }
>
> I'm assuming that the fast enumeration loop itself does something like this
> behind the scenes for each object in the array:
> id anObject = [anArray objectAtIndex:i]
>
> so are these temp objects created during the enumeration released
> automatically at the end of the loop, or is it work wrapping the whole
> thing in an autoreleasepool?
>
> @autoreleasepool {
> for (id anObject in anArray) {
> // do some stuff
> }
> }
>
> Thanks
> _______________________________________________
>
> 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


_______________________________________________

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: Fast Enumeration and temporary objects/autoreleasing
      • From: Patrick Robertson <email@hidden>
References: 
 >Fast Enumeration and temporary objects/autoreleasing (From: Patrick Robertson <email@hidden>)

  • Prev by Date: When to declare variables and the compiler's intelligence
  • Next by Date: Re: Fast Enumeration and temporary objects/autoreleasing
  • Previous by thread: Fast Enumeration and temporary objects/autoreleasing
  • Next by thread: Re: Fast Enumeration and temporary objects/autoreleasing
  • Index(es):
    • Date
    • Thread