在类中定义一个property,作为block用
@property (nonatomic, strong) void (^ myBlock)();
然后想在property在代码中使用时为block创建了一个获取,如果property是NSArray,就可以这样设置:
@synthesize myProperty = _myProperty;
- (NSArray *)myProperty {
if (_myProperty) {
_myProperty = [[NSArray alloc] init];
}
return _myProperty;
}
但是property是block,应该怎么设置实例化?