Sorry for asking a totally basic question, but if I have a synthesized property that is retained.
self.myProperty = [[NSObject alloc] init];
will cause a memory leak?
So am I correct in thinking that I need to do
self.myProperty = [[NSObject alloc] init];
[self.myProperty release];
in order to balance? Because that seems dumb.
Standard practice would be to use
autoreleasein that situation. So:This is because
initreturns a retained object, and since your property also retains it, you’ll have to release it.Edited to add: @walkytalky makes a good point in the comments that it is actually
allocthat retains the object,initjust returns it.