• 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: Storing a block in a CF/NSMutableDictionary?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Storing a block in a CF/NSMutableDictionary?


  • Subject: Re: Storing a block in a CF/NSMutableDictionary?
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 08 Apr 2011 21:03:14 -0700

On Fri, Apr 8, 2011 at 5:56 PM, Rick Mann <email@hidden> wrote:
> Hmm. Reading the docs there again, it also says:
>
> "Typically, you shouldn’t need to copy (or retain) a block. You only need to make a copy when you expect the block to be used after destruction of the scope within which it was declared. Copying moves a block to the heap."
>
> So, I expressly copied my block and stored the copy in the dictionary. That worked (I mistakenly conflated the fact that keys typically get copied, not objects).

But it references a stack variable, which is going to get destroyed as
soon as the syntactical block enclosing the declaration of your code
block (*sigh* for namespace collision) goes out of scope.

If you reference a stack variable from your block, you cannot allow
that block to escape the scope of that variable.

--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: Storing a block in a CF/NSMutableDictionary?
      • From: Kyle Sluder <email@hidden>
References: 
 >Storing a block in a CF/NSMutableDictionary? (From: Rick Mann <email@hidden>)
 >Re: Storing a block in a CF/NSMutableDictionary? (From: Kyle Sluder <email@hidden>)
 >Re: Storing a block in a CF/NSMutableDictionary? (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Test for TCP port
  • Next by Date: Re: Storing a block in a CF/NSMutableDictionary?
  • Previous by thread: Re: Storing a block in a CF/NSMutableDictionary?
  • Next by thread: Re: Storing a block in a CF/NSMutableDictionary?
  • Index(es):
    • Date
    • Thread