I want to know what the following means. I have to release it? I did not allocate memory for it. Method is also class method. Any help?
object = [[class method] retain];
I want to know what the following means. I have to release it? I did not allocate memory for it. Method is also class method. Any help?
object = [[class method] retain];
Prior version 2.0 Objective-C used a reference counter strategy to track and manage memory. From 2.0 a garbage collector can be activated, BUT, not yet available on the iPhone.
Have a look here about Objective-C reference counter strategy.
Assuming "method" is following convention it will be returning either an autoreleased reference, or something guaranteed to be valid during the scope of the caller (unless the method is called alloc, new or copy). So without the retain the reference should be valid in the immediate call context but if you wanted to hold on to it in an instance variable you need the retain.
So, if you'll only be using "object" in the immediate context of the call you don't need the retain - otherwise you do.
If you'll be doing retain counts it's quite important you familiarise yourself with the semantics. There are many suitable references on the web, but I'll repeat the one epatel has already given, which is another stackoverflow question.