TAGS :Viewed: 11 - Published at: a few seconds ago

[ What am I doing wrong with this method definition and call? ]

I have this in my class header:

typedef void(^DBSuccessBlock)();
typedef void(^DBErrorBlock)(int errorNumber, NSString* description);

- (void) connect:(NSString*) path isFile:(BOOL) flag
        success:(DBSuccessBlock) success
          error:(DBErrorBlock) error;

This is how I'm trying to call the method:

[db connect:filePathName isFile:YES success:^{
    // initialize db here if necessary
} error:^(int errorNumber, NSString *description) { //error on this line
    return nil;

The error line is giving me this compile error: Incompatible block pointer types sending 'void *(^)(int, NSString *_strong)' to parameter of type 'DBErrorBlock' (aka 'void (^)(int, NSString *_strong)')

The only difference I see is void* vs void and I'm not sure why. Can anyone help me figure out why I'm getting this error? Thanks.

Answer 1

You are returning the value nil in a block with return type void. Remove the return nil line.