I am somewhat confused about when things are allocated on the heap (and I need to release them) and when they are allocated on the stack (and I don\'t need to relese them).
In Objective-C, it's easy: all objects are allocated on the heap.
The rule is, if you call a method with alloc
or new
or copy
in the name (or you call retain
), you own that object, and you must release it at some point later when you are done with it. There has been plenty written on the subject.
The example you give is a special case: that's a static string, I believe it is actually located in the program's data segment (on the heap), but it's static so you don't need to worry about releasing it.