美文网首页
Category 增加字段

Category 增加字段

作者: 西边雨 | 来源:发表于2015-09-08 14:34 被阅读27次

    NSObject+AssociatedObject.h

    @interfaceNSObject(AssociatedObject)

    @property(nonatomic,strong)idassociatedObject;

    @end

    NSObject+AssociatedObject.m

    @implementationNSObject(AssociatedObject)

    @dynamicassociatedObject;

    -(void)setAssociatedObject:(id)object{

          objc_setAssociatedObject(self,@selector(associatedObject),object,OBJC_ASSOCIATION_RETAIN_NONATOMIC);

    }

    -(id)associatedObject{

           returnobjc_getAssociatedObject(self,@selector(associatedObject));

    }

    相关文章

      网友评论

          本文标题:Category 增加字段

          本文链接:https://www.haomeiwen.com/subject/oxxpcttx.html