2019独角兽企业重金招聘Python工程师标准>>>
前言:我是赵大财,10秒学会系列,绝不废话连篇! 力求10秒,让你了解会用改知识点
作用:category中需要自己的属性
普通类h
//
// DCRuntime.h
// dacai
//
// Created by point on 16/4/4.
// Copyright © 2016年 赵大财. All rights reserved.
//
#import
@interface DCRuntime : NSObject
@property (copy, nonatomic) NSString *name;
-(void)run;
@end
普通类m
//
// DCRuntime.m
// dacai
//
// Created by point on 16/4/4.
// Copyright © 2016年 赵大财. All rights reserved.
//
#import "DCRuntime.h"
@implementation DCRuntime
-(void)run {
NSLog(@"%s",__func__);
}
@end
分类h
//
// DCRuntime+Extention.h
// dacai
//
// Created by point on 16/4/4.
// Copyright © 2016年 赵大财. All rights reserved.
//
#import "DCRuntime.h"
@interface DCRuntime (Extention)
@property (copy, nonatomic) NSString *job;
-(void)makeMoney;
@end
分类m
//
// DCRuntime+Extention.m
// dacai
//
// Created by point on 16/4/4.
// Copyright © 2016年 赵大财. All rights reserved.
//
#import "DCRuntime+Extention.h"
#import
@implementation DCRuntime (Extention)
static char *JobKey = "jobKey";
- (void)setJob:(NSString *)job {
objc_setAssociatedObject(self, JobKey, job, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
-(NSString *)job {
return objc_getAssociatedObject(self, JobKey);
}
-(void)makeMoney {
NSLog(@"%@ %@ %@",self.name,self.job,@"很多很多的钱");
}
@end