Reputation: 19507
When I set an object = nil
, will it be garbage collected or do I have to release it?
Upvotes: 0
Views: 117
Reputation: 69469
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.
Upvotes: 0
Reputation: 17317
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.
Upvotes: 1