Reputation: 898
I want to know what is difference between self.object
and self->object
? how can we able to release memory in ARC using self
?
Upvotes: 0
Views: 250
Reputation: 122381
self
is a pointer, so self->object
correctly references object
.
self.object
however is Objective-C syntactic sugar for [self object]
and will call the getter method (-(Object *)object
) (or the setter method [self setObject:]
if you are assigning).
If you are using ARC then you don't explicitly need to do anything to release memory.
Upvotes: 3
Reputation: 9392
self.object
calls the setter method, which does memory management such as retaining the object. self->object
sets/accesses the object directly which doesn't do any memory management. Generally you wouldn't want to access an object's ivar directly, so just create setters/getters for object
and use self.object
.
Upvotes: 0