Reputation: 96391
Assuming that header declaration contains
@property(nonatomic, assign) DoublyLinkedList *doublyLinkedList;
Is there any difference between
[[self doublyLinkedList] release];
[self setDoublyLinkedList:nil];
and
[doublyLinkedList release];
doublyLinkedList= nil
Is one preferred over another? Why?
Upvotes: 2
Views: 45
Reputation: 12087
There is no difference.
The second option might be ever so slightly faster, because it doesn't use the getter/setter methods.
Just so we're clear, are you retaining doublyLinkedList when you assign it? Because otherwise you're over-releasing.
And unless you have a good reason, I would skip all this and use retain instead of assign, and self.doublyLinkedList = nil to release/clear it.
e.g.
definition
@property(nonatomic, retain) DoublyLinkedList *doublyLinkedList;
in use
self.doublyLinkedList = nil;
and on dealloc
-(void)dealloc{self.doublyLinkedList=nil;[super dealloc];}
Upvotes: 1