I have some Obj-C code in which I have a class with many blocks as members.
The property in question is the following:
@property(nonatomic, readonly, retain) BOOL(^truthPredicate)(int, NSMutableDictionary*);
And is implemented in a @synthesize statement in the .m file. In one of the init methods for the class, I tried to set the property to a literal block:
truthPredicate=^(int val, NSMutableDictionary* params) {return val >= MANodeTruthThreshold ? YES : NO;};
This signals a compiler error. The compiler, despite the fact that YES and NO are defined to be (BOOL)1 and (BOOL)0, and BOOL being defined as signed char, the compiler insists that I’m trying to assign an int returning block to a BOOL returning variable. How do I make Obj-C realize that I’m returning BOOLs, not ints?
Apparently, type inference is failing you. Try the more verbose syntax: