声明文件
#import <Foundation/Foundation.h>
@interface NSObject (SendInfo)
@property (nonatomic,assign) id sendInfo;
@end
实现文件
#import "NSObject+SendInfo.h"
#import <objc/runtime.h>
static void * kSendInfoKey = &kSendInfoKey;
@implementation NSObject (SendInfo)
@dynamic sendInfo;
- (id)sendInfo{
return objc_getAssociatedObject(self, kSendInfoKey);
}
- (void)setSendInfo:(id)sendInfo{
return objc_setAssociatedObject(self, kSendInfoKey, sendInfo, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end
网友评论