#import <Foundation/Foundation.h>
@interface SmClass (Additional)
@property (nonatomic, strong) NSMutableArray *someContainer;
@property (nonatomic, strong) id anotherObj;
@end
#import "SmClass+Additional.h"
#import <objc/runtime.h>
const void *containerKey = &containerKey;
@implementation SmClass (additional)
- (NSMutableArray *)someContainer
{
return objc_getAssociatedObject(self, &containerKey);
}
- (void)setSomeContainer:(NSMutableArray *)someContainer
{
objc_setAssociatedObject(self, &containerKey, someContainer, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
//
- (id)anotherObj {
return objc_getAssociatedObject(self, _cmd);
}
- (void)setAnotherObj:(id)obj {
objc_setAssociatedObject(self, @selector(anotherObj), obj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end
网友评论