开发者

Does setting an object to nil flag it for garbage collection

When I set an object = nil, will it be garbage collected or do I have t开发者_C百科o release it?


The current iOS doesn't support garbage collection, so no.

However, if object is a @property of another object and is defined something like:

@property (nonatomic, retain) id object;

Then calling myObject.object = nil will autorelease the previous value of object.


There is no garbage collection in Objective-C (on iOS as state by ThomasW).

If you create an object autorelease object, then the autorelease pool will clean up the object if its retain count hits 0.

All other object you should release your self.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜