openfrog
openfrog

Reputation: 40765

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.

Upvotes: 19

Views: 5880

Answers (1)

Till
Till

Reputation: 27597

Simply import the runtime header:

#import <objc/runtime.h>

Upvotes: 63

Related Questions