cro*_*ant 0 memory-management objective-c
好的,如果我有这个:
NSString *lastPushed = (NSString *)[tagStack objectAtIndex:[tagStack count]-1];
.//do something with the last pushed element locally
.//do more cstuff here
.//after doing all the stuff needed in the function
[lastPushed release];
Run Code Online (Sandbox Code Playgroud)
其中tagStack是NSMutableArray
如果我发布了lastPushed,因为它没有被复制或者被引入,它是否只会释放这个引用,还是会实际释放mutableArray中的对象?
你没有alloc,new或者copy或者mutableCopy lastPushed,那你为什么释放了吗?
由于lastPushed是指向数组中对象的指针,因此您将释放它.当你的数组认为它有一个指向某个对象的有效指针但是你已经释放它并且它被编辑时,这可能会导致一个问题dealloc.
| 归档时间: |
|
| 查看次数: |
62 次 |
| 最近记录: |