Can myArray be safely released before the block?
NSMutableArray *myArray = [[NSMutableArray alloc] init];
[myArray addObject:@"a"];
[myArray addObject:@"b"];
// releasing here causes an invalid object to be used inside the block?
[myArray release];
CCCallBlock *block = [CCCallBlock actionWithBlock:^{
// print myArray contents to console
}];
[myNode runAction:block];
No, you cannot release the array before the block, because the objects inside the array and the array itself will not be usable after the call of release, before your block gets a chance to retain it.
You can make your array autoreleased, in which case the release would happen after the function exits.