AAChartKit 中 宏定义添加属性和set方法

//propertyModifier  strong ,weak,assign
//SQBIndexAlertManager  类名,在哪个里面添加
//propertyPointerType  属性类型 NSString *之类
//propertyName  属性名 string
#define QBZProStatementAndPropSetFuncStatement(propertyModifier,className,propertyPointerType, propertyName)      \
@property(nonatomic,propertyModifier)propertyPointerType  propertyName;                                                 \
- (className *(^) (propertyPointerType propertyName)) propertyName##Set;

set方法是使用的链式语法,

propertyName##Set

等价于

[NSString stringWithFormat:@"%@Set",propertyName];

使用

@interface IndexAlertManager : NSObject

QBZProStatementAndPropSetFuncStatement(strong,IndexAlertManager,NSString *,name);
@end

@implementation IndexAlertManager
-(void)test
{
        self.name = @"qbz";
        self.nameSet(@"qbz");
}

宏定义等价于

@property(nonatomic,strong)NSString  *names;          
- ( IndexAlertManager * (^)(NSString *names))namesSet
{
    return ^(NSString *names){
        self.names = names;
        return self;
    };
}

使用
-(void)test
{
        self.names = @"qbz";
        self.namesSet(@"qbz");
}
                                       

你可能感兴趣的:(AAChartKit 中 宏定义添加属性和set方法)