Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is objc_setAssociatedObject not available in iOS?

I'm trying to add "properties" to categories using associate objects API.

objc_setAssociatedObject(self, &kIsAnimatingAssocObjKey, animating, 
OBJC_ASSOCIATION_RETAIN_NONATOMIC);

Xcode complains:

Implicit declaration of function 'objc_setAssociatedObject' is invalid in C99

and

Use of undeclared identifier 'OBJC_ASSOCIATION_RETAIN_NONATOMIC'

Xcode 4.5.2, iOS SDK 6 with deployment target 6. It does not work.

None of the articles on obj_assoc mention that I must import anything special.

like image 298
openfrog Avatar asked Dec 18 '12 15:12

openfrog


1 Answers

Simply import the runtime header:

#import <objc/runtime.h>

like image 102
Till Avatar answered Oct 01 '22 00:10

Till