iPhone memory management: a release after setting self.someProperty = nil
Posted
by
ddawber
on Stack Overflow
See other posts from Stack Overflow
or by ddawber
Published on 2011-01-08T22:21:37Z
Indexed on
2011/01/09
0:54 UTC
Read the original article
Hit count: 207
I am reading the LazyTableImages code that Apple have released and they do something to this effect (in an NSOperation subclass):
- (void)dealloc {
[myProperty release];
[myProperty2 release];
}
- (void)main {
//
// Parse operation undertaken here
//
self.myProperty = nil;
self.myProperty2 = nil;
}
My thinking is that they do this in case dealloc
is called before setting properties to nil.
Is my thinking correct here? Are the releases unnecessary, as self.myProperty = nil
effectively releases myProperty
?
One thing I have noticed in this code is that they don't release
all retained objects in dealloc
, only some of them, which is really the cause for my confusion.
Cheers
© Stack Overflow or respective owner