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];
}

你可能感兴趣的:(ios)