I have a method that returns a block and another method that uses a method:
- (MyBlock)blockForParameter:(id)param
{
MyBlock theBlock = ^(){NSLog(@"Param: %@", param);};
return theBlock;
}
- (void)methodUser
{
MyBlock theBlock = [self blockForParameter:something];
[self.allBlocks addObject:theBlock];
}
The question is when should a block be copied? Do I have to copy the block when I return it to blockForParameter, or do I need to copy it when I add it to the array?
thank
source
share