CBSE BOARD X, asked by sumitgupta51, 8 months ago

how can you assign the value of answer block to a variable​

Answers

Answered by thezvezda1104
0

I'm getting an error

Variable is not assignable (missing __block type specifier)

on the line aPerson = participant;. How can I make sure the block can access the aPerson variable and the aPerson variable can be returned?

Person *aPerson = nil;

[participants enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {

Person *participant = (Person*)obj;

if ([participant.gender isEqualToString:@"M"]) {

aPerson = participant;

*stop = YES;

}

}];

return aPerson;

Similar questions