Well, on iPhone, it would get deallocated with the next pool drain, not garbage collected (since garbage collection does not exist for iPhone as of now.)
foo = myshinyobject is ok if you use instantiate it like [[SomeClassThing alloc] initetc] rather than one of the convenience methods like [SomeClassThing thing] since those are supposed to be returned with a retain count of 0.
I forgot what I was getting at.
Re:iPhone development emergency guide
by einarvollset on Wednesday July 22, 2009 @11:22AM
(#717989)
Well, sort of.
If you do an alloc/init, then you need to release it (or you leak). If you're assigning to self.foo, then you can just release the thing you created after assigning it. If you assigned it to foo, and then release it, then you're in the position I mentioned above.
Well no, the difference (inside a class) of:
this.foo = myshinyobject
and
foo = myshinyobject
is nothing in Java. In Objective-C,
self.foo = myshinyobject
and
foo = myshinyobject
are different. Particularly with regards to the @property (retain) magic; if you forget self.foo and use foo, then myshinyobject might get garbage collected. Which is not what you'd expect with a retained property.