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;
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…