Instance instance variables in Objective-C categories with associative references - error "Using undeclared identifier" OBJC_ASSOCIATION_RETAIN "

I am trying to create "fake" instance variables in categories 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_RETAINfor the following code snippet:

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

What has changed for iOS 6.1?

What did I miss?

+5
source share
2 answers

It seems that I have not imported: #import <objc/runtime.h>

+1
source

#import <objc/runtime.h>, , objc-runtime, .

, varaibles , , iVars , , @dynamic, , .

+1

All Articles