我一直很困惑如何处理从方法中返回NSMutableArray时的释放问题。我甚至不确定是否应该释放它。
我的代码如下:
-(NSArray *)methodToCall {
NSMutableArray *mutArray = [[NSMutableArray alloc] initWithCapacity:10];
//Fill the array with stuff here
[mutArray release]; //Am I suppose to have this to keep the memory down?
return mutArray;
}
我的问题是在代码中是否应该有[mutArray release];
。能否有人解释一下?我很困惑,希望尽可能保持代码的干净和无泄漏。