【发布时间】:2011-11-20 00:33:39
【问题描述】:
在我的一个函数中,我有一个 while 循环,在某些情况下它可能需要临时创建一个对象。我的代码如下所示:
while(c < end){
if(specialCase){
Object *myObject = [Object alloc];
//do stuff with myObject
//I tried [myObject dealloc] here, but it crashed when this method was called.
}
c++;
}
代码按原样运行良好,但我担心内存泄漏。我想知道是否应该以及如何释放 myObject。
【问题讨论】:
标签: iphone ios memory-management ios4 dealloc