`

ios Associative 扩展属性

 
阅读更多
@dynamic和@synthesize
http://blog.csdn.net/qie2327023/article/details/7863102

http://blog.csdn.net/linkai5696/article/details/6644400



@dynamic progress;
static const char *KeyProgress = "KeyProgress";
- (UIProgressView *)progress
{
    return objc_getAssociatedObject(self, KeyProgress);
}

-(void)setProgress:(UIProgressView *)pro
{
    if (self.progress != nil)
    {
        [self.progress removeFromSuperview];
//        [self.progress release];
        self.progress = nil;
    }
   
    objc_setAssociatedObject(self, KeyProgress, pro, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    [self addSubview:pro];
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics