假设你有 Block 类
Class Block : NSObject
现在,你想创建 C 风格的数组
Block *blocks[5]; // or calling malloc()
Block *aBlock = [[Block alloc] init];
blocks[0] = aBlock;
// at this point, aBlock will be hand over to array blocks slot.
// not like NSArray, object of 'Block' will not retain by @property(retain)
// or should I call retain before hand over the value into its array and release afterward?
// should I still call below code to release object ?
// [aBlock release];
有人可以向我解释一下我之后是否还需要释放 aBlock 对象吗?
最佳答案
不,因为原始数组不会保留每个 Block
对象。所以如果你释放它,所有的 Block
对象都会在函数退出作用域时被清除
关于ios - 我应该释放原始 C 数组中的对象吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12926645/