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

Re: Threaded drawing


  • Subject: Re: Threaded drawing
  • From: Seth Willits <email@hidden>
  • Date: Fri, 06 Dec 2013 09:24:03 -0800

On Dec 6, 2013, at 8:05 AM, email@hidden wrote:

>>> On 6 Dec 2013, at 11:26 am, Graham Cox <email@hidden> wrote:
>>>
>>>               NSBlockOperation* op = [NSBlockOperation blockOperationWithBlock:^
>>>               {
>>>                   CGContextClipToRect( ncx, tileRect );
>>>
>>>                   [self drawTile:tileRect inContext:ncx];
>>>               }];
>>
>>
>> A question for blocks experts:
>>
>> Is the value of <tileRect> here captured when the block is created,or when it is run?
>>
>> If the latter, it’s going to be probably wrong most of the time, so how can I make sure it is captured when the block is created?
>>
>
>
> It's the latter IIRC
> You'll want to capture it outside and prefix it to be block scoped.


No it’s not and no you don’t.


	int x = 3;
	void (^block)(void) = ^{ NSLog(@"%d", x); };
	x = 5;
	block();

The result is 3 not 5.


--
Seth Willits




_______________________________________________

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: Threaded drawing
      • From: John McCall <email@hidden>
References: 
 >Threaded drawing (From: Graham Cox <email@hidden>)
 >Re: Threaded drawing (From: Graham Cox <email@hidden>)
 >Re: Threaded drawing (From: Graham Cox <email@hidden>)
 >Re: Threaded drawing (From: email@hidden)

  • Prev by Date: Re: Threaded drawing
  • Next by Date: Re: Threaded drawing
  • Previous by thread: Re: Threaded drawing
  • Next by thread: Re: Threaded drawing
  • Index(es):
    • Date
    • Thread