Search code examples
objective-cblock

Block type drives me nuts


I have this code:

typedef void (^OutputBlockType) (void (^) (NSString*));

static  OutputBlockType outputBlock;


+(void) logMessage:(NSString*) msg {
 NSString* bla = @"bla"; 
 outputBlock(bla);
}

Granted, that the original code is a bit more complex. Still.. Xcode (4.3) is not happy with this code and throws me an

Passing 'NSString *_strong' to parameter of incompatible type 'void (^_strong)(NSString *__strong)';

message which, basically, tells me nothing at all. Does anyone have a clue as to what I'm doing wrong here?


Solution

  • The message is more or less clear: you have declared your block as taking a block that takes a string argument, but you are passing it a string instead.

    If you wanted a block that takes a string, here is a typedef for it:

    typedef void (^OutputBlockType)(NSString*)