[AsyncRequest performGetRequestWithUrl:[NSString stringWithFormat:@"http://%@/api/streams/%d", @"server.herokuapp.com", userId]
completionHandler:^(NSDictionary *result, NSError *error) {
// Create new SBJSON parser object
NSError *e;
NSArray *jsonArray =[NSJSONSerialization JSONObjectWithData:result options:NSJSONReadingMutableContainers error: &e];
NSLog(@"parse result to JSON object with jsonArray: %@ and error: %@", jsonArray, e.description);
if ([jsonArray valueForKey:@"error"]) {
return nil;
}
NSLog(@"getStreams size of the return array: %d", [jsonArray count]);
NSMutableArray* data = [[NSMutableArray alloc] initWithCapacity:0];
if (jsonArray) {
data = [[NSMutableArray alloc] initWithCapacity:[jsonArray count]];
for (NSDictionary *item in jsonArray) {
NSLog(@"item: %@", item);
[data addObject:[[Stream alloc] initWithJSONObject:item]];
}
}
onComplete(data, error);
}];
我在这段代码上遇到奇怪的错误。它显示错误消息“获取不兼容的块指针类型将 void *(^)(NSDictionary *_strong, NSError *_strong) 发送到 'void (^)(NSDictionary *_strong, NSError *_strong) 类型的参数'
这是函数签名:
+(void)performGetRequestWithUrl:(NSString *)requestUrl completionHandler:(void (^)(NSDictionary *result, NSError *error))completionBlock