Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting incompatible block pointer types sending void *(^)

[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);

}];

I am getting weird error on this code. It shows the error message "Getting incompatible block pointer types sending void *(^)(NSDictionary *_strong, NSError *_strong) to parameter of type 'void (^)(NSDictionary *_strong, NSError *_strong)'

Here is the function signature:

+(void)performGetRequestWithUrl:(NSString *)requestUrl completionHandler:(void (^)(NSDictionary *result, NSError *error))completionBlock
like image 539
flashsnake Avatar asked Sep 23 '12 03:09

flashsnake


1 Answers

change "return nil" to "return"

like image 148
Elden Avatar answered Oct 22 '22 11:10

Elden