Search code examples
iosobjective-ccocoa-touchios6automatic-ref-counting

Faking instance variables in Objective-C categories with Associative References - Error "Use of undeclared identifier 'OBJC_ASSOCIATION_RETAIN"


I am trying to create "fake" instance variables in categories by using objc_setAssociatedObjectas described in this post.

However, I get the following error using ARC in iOS 6.1: Use of undeclared identifier 'OBJC_ASSOCIATION_RETAIN for the following code snippet:

- (void)setStyleName:(NSString *)styleName
{
   objc_setAssociatedObject(self, kDHStyleKey, styleName,
   OBJC_ASSOCIATION_RETAIN);
}

Has anything changed for iOS 6.1?

What did I miss?


Solution

  • It seems that I did not import: #import <objc/runtime.h>