objective c - setting BOOL variable inside block -


i'm trying set bool value defined in class inside block, can't see able set it. code.

 __weak __block sptween *tween2weak = tween;     __block bool buttonscroll2 = buttonscroll;      tween.oncomplete = ^{         [sparrow.juggler removeobject:tween2weak];         buttonscroll2 = no;     }; 

i presume when buttonscroll2 = no, im doing setting separate variable , not original, how original inside block then?

you correct, once value of buttonscroll gets copied buttonscroll2, changes buttonscroll2 have no effect on original buttonscroll.

if buttonscroll instance variable of object, should able access using __weak self pattern:

__weak __block sptween *tween2weak = tween; __weak typeof(self) weakself = self; tween.oncomplete = ^{     [sparrow.juggler removeobject:tween2weak];     myclass *strongself = weakself;     strongself->buttonscroll = no; }; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -