最佳答案
我得到一个错误
变量不可赋值(缺少__block类型说明符)
aPerson = participant;
。我如何确保块可以访问aPerson
变量和aPerson
变量可以返回?
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;