I am creating a property on a class that is gonna be a block.
It is being defined like
@property (nonatomic, strong) void (^ myBlock)();
I would like to do lazy creation of that property, so I want to create a getter for that block to run when the the property is used by some code.
If the property was not a block and was a NSArray for example, I would do the setter like this:
@synthesize myProperty = _myProperty;
- (NSArray *)myProperty {
if (_myProperty) {
_myProperty = [[NSArray alloc] init];
}
return _myProperty;
}
How do I do a getter (lazy instantiation) for a property that is a block?
NOTE: this block is inside a singleton.
thanks
1 Answer