Reputation: 11537
I am wondering what is the scope of variables when using the same name of a variable within and outside a block. An example will talk from itself:
NSSet *test = [NSSet setWithObjects@"Test"];
void (^onComplete)(id) = ^(NSSet *test) {
// do we see the variable define as an argument of the block or the variable define outside of the block?
NSSet *test2 = test;
}
NSSet *test3 = test;
Is there any possible conficts here?
Upvotes: 1
Views: 45
Reputation: 122439
Local variables hide outer scopes. So in the block, test
is the parameter, not the outside variable.
Upvotes: 2