NSObject添加屬性

/**
 * @file AnimateObject.h
 * @brief 爲NSobject添加customAnimating屬性
 */

@interface NSObject(CustomAnimate)


@property (retain, nonatomic) NSNumber *customAnimating;

@end

/**
 * @file AnimateObject.m
 */

#import "AnimateObject.h"
#import <objc/runtime.h>

static const void *customAnimatingKey = &customAnimatingKey;

@implementation NSObject(CustomAnimate)

- (NSNumber *)customAnimating {
    return objc_getAssociatedObject(self, customAnimatingKey);
}

- (void)setCustomAnimating:(NSNumber *)animating{
    objc_setAssociatedObject(self, customAnimatingKey, animating, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

@end


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章