有没有人知道如何同步接收发布数组的响应? 我在这里:
[manager postObject:objectArray path:@"" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *result) {
NSLog(@"Loading mapping result: %@", result.firstObject);
res = [NSMutableArray arrayWithArray:[result array]];
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
if (operation.error) {...}
但我希望得到[result array];
毫不拖延
答案 0 :(得分:0)
如果您只想阻止当前线程
__block BOOL operationDone = NO;
[[RKObjectManager sharedManager] getObject:nil
path:path
parameters:parameters
success:^(RKObjectRequestOperation *operation, RKMappingResult *blockMappingResult) {
// Do something
operationDone = YES;
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
// Do something
operationDone = YES;
}];
while(!operationDone) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}