The objc_setAssociatedObject function expects an Objective-C object for the third parameter. But you are trying to pass a non-object BOOL value.
This is no different than trying to add BOOL to NSArray . You need to wrap BOOL .
Try:
objc_setAssociatedObject(self, animatingKey, [NSNumber numberWithBool:value], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
Of course, you will need to extract the BOOL value from NSNumber when you get the associated object later.
Update. Using modern Objective-C, you can:
objc_setAssociatedObject(self, animatingKey, @(value), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
source share