문제

Can you please write for me a block which conforms to this definition: (BOOL(^)(id))block.

The closest I have gotten is:

typedef BOOL (^birds)(MyObject*);
birds c = ^(MyObject* p){ return (BOOL)[p.something boolValue]; };

But it seems passing this c in a message who wants (BOOL(^)(id))block is a no go.

도움이 되었습니까?

해결책

if a Block BOOL (^block)(id) is expected you need to pass such a block and not a BOOL (^block)(MyObject *).

So try this:

typedef BOOL (^birds)(id);
birds c = ^(id pp) { MyObject *p = (MyObject *) pp; return [p.something boolValue]; };
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top