---
title: "ios Associative 扩展属性"
author: "xserver"
date: "2013-01-08T16:45:58Z"
tags: []
categories: ["编程语言"]
slug: "ios-associative"
draft: false
lastmod: "2013-01-08T16:45:58Z"
id: 1766350
url: "https://xserver.iteye.com/blog/1766350"
---

@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 = nil;
    }
    
    objc_setAssociatedObject(self, KeyProgress, pro, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    ;
}