I\'m slowly teaching myself cocoa for the iPhone(through the Stanford Class on iTunes U) and I\'ve just gone through the part on memory management, and I wanted to hopefully
The rule is simple: if you alloc
, copy
or retain
, it's your responsibility to release
. If you didn't, it's not. However, if you need to rely on an object staying around, you have to retain
(and subsequently release
).
We can treat the string literal according to the rules - you don't need to release
it because you don't own it. That's simple; there's no need to worry about whether they're special cases or not, just follow the rules and you'll be fine.
I wrote up a blog post with a collection of articles about the Cocoa memory management rules; I'd recommend following up some of the references.