RYLazyProperty
RYLazyProperty copied to clipboard
好玩的Runtime --- 一行代码解决懒加载
好玩的Runtime: 一行代码解决懒加载
解决问题:
- 更方便的懒加载
- (Animal *)animal {
if (_animal) {
_animal = [Animal new];
}
return _layerView;
}
- 部分数据的容错
self.nameLabel.text = [NSString stringWithFormat:@"动物名称:%@", self.animal.name];
使用方法:
[Animal ry_setLazyPropertyArr:@[@"name",@"foots",@"attribute",]];
[ViewController ry_setLazyPropertyArr:@[@"animal"]];
该方法仅支持 Objective-C
对象