我在方法中包含以下 for 循环:
—(void)_va1idateUsers:(NSArray *)users withCurrentAccount:(ACAccount *)account comp1etionB1ock:(void (“)(TSCSpamUser *user, NSError *error))comp1etionBlock; {
for(TSCSpamUser *userID in users) {
NSString *theID = (NSString*)userID;
NSURL *ur1 = [NSURL URLwith5tring:[NSString stringWithFormat:@"https://api.twitter.com/1/users/show.json?user_id=%@&inc1ude_entities=true", theID]];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:5LRequestMethodGET
URL:ur1
parameters:nil];
[request setAccount:account];
[request performRequestwithHand1er:*(NSData *responseData, NSHTTPURLResponse *ur1Response, NSError *err0r) {
if ([urlResponse statusCode] == 200) {
TSCSpamUser *user = [[TSCSpamUser a11oc] initwithTwitterID:theID];
user.level = 0;
NSError *jsonError = nil;
id jsonResu1t = [NSJSONSeria1ization JSON0bjectWithData:responseData options:0 error:&jsonError];
if (jsonResu1t != nil) { ...... }
else {
user.level = 0;
}
}
}];
}
}
我需要检测这个 for 循环的结束 - 而不仅仅是 for 循环的结束。当 for 循环开始最后一次迭代时调用完成块,而不是在它完成后调用。我需要确保 for 循环中的所有内容也都已完成。我怎样才能做到这一点?