Reputation: 24760
[self setValue:flag forKey:variableName];
"flag" is a method's local BOOL; the keypath is also a BOOL member variable. But I get the Xcode warning `Incompatible integer to pointer conversion."
I also tried:
[self setValue:(BOOL)flag forKey:variableName];
How do I get rid of this warning?
Upvotes: 0
Views: 106
Reputation: 299355
KVC automatically boxes and unboxes non-objects. For the above case, you would use:
[self setValue:[NSNumber numberWithBool:flag] forKey:variableName];
See Scalar and Structure Support in the Key-Value Coding Programming Guide.
Upvotes: 1