johnbakers
johnbakers

Reputation: 24750

Changing variable inside block

I have this defined at top of a method:

__block BOOL flag;

I have a UIView animation block, and inside it I have this:

flag=YES;
NSLog(@"the value of the flag is %i",flag);

However, instead of returning 1, it logs as 0.

Other things in the block are running correctly. What could be happening here?

Upvotes: 0

Views: 176

Answers (1)

Jason
Jason

Reputation: 814

Are you sure you don't have any method accidentally set flag = NO;? Because it looks like everything is fine. I even tried it by myself and I can get it logged as 1.(Same code you used)

Upvotes: 2

Related Questions