category添加属性

转自http://www.tuicool.com/articles/FZn6Rfa


#import 

@interfaceUIViewController (Base)

@property(nonatomic,strong)NSMutableArray* dataArray;

@end

----------------------------------------------------------------------------------

#import 

@implementationUIViewController (Base)

- (NSMutableArray*)dataArray{

    returnobjc_getAssociatedObject(self,@selector(dataArray));

}

- (void)setDataArray:(NSMutableArray*)dataArray{

    objc_setAssociatedObject(self,@selector(dataArray), dataArray,OBJC_ASSOCIATION_RETAIN_NONATOMIC);

}

@end

你可能感兴趣的:(category添加属性)