开发者

What happens if we try to use object removed from an nsarray ar nsmutable array?

I'v开发者_运维问答e searched it alot but most of the times found answer related to releasing objects not for removing object. Any help would be highly appreciated.


what do you mean by "removed from Array"? If you have the object assigned to any other variable - nothing will happen. (just that the internal retain count will be decreased by one - but that's internal) If, however, the object is not assigned to any other variable, sooner or later the system will claim the memory occipied by the object. Nobody knows when this happens. That's why the object is undefined right after you remove it from the array in this case.


You can't remove objects from a NSArray, as it is immutable. Removing objects from a NSMutableArray (see docs) is straightforward:

[myMutableArray removeObject: anObject];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜