What does accurate preservation mean?

I want to know what this means. Should I release it? I have not allocated memory for this. A method is also a class method. Any help?

object = [[class method] retain];

      

+2


source to share


2 answers


Prior to version 2.0 of Objective-C, a counter reference was used to track and manage memory. Since 2.0, the garbage collector can be activated BUT not yet available on the iPhone.

Take a look here about the Objective-C referencing strategy.

Now, 2011, it looks like the GC engine has been deprecated in favor of an Automatic Reference Counting (ARC) engine.



From Apple

Automatic reference counting

Automatic Reference Counting (ARC) for Objective-C makes memory management a compiler task. By enabling ARC with Apple's new LLVM compiler, you no longer need to enter a save or release, which greatly simplifies the development process while reducing crashes and memory leaks. The compiler has a complete understanding of your objects and releases each object the moment it is no longer in use, so applications run as fast as possible with predictable and smooth performance.

+5


source


Assuming the "method" conforms to the following convention, it will return an autoreleased reference or something guaranteed to be valid while the caller is active (unless the method is called alloc, new, or copy). Thus, without persistence, the reference must be valid in the context of the immediate call, but if you want to store it in an instance variable, you need to store it.

So, if you only use "object" in the immediate context of the call, you don't need to save - otherwise you do.



If you are doing the math, it is very important that you become familiar with the semantics. On the Internet, there are many appropriate links, but I will repeat fooobar.com/questions/3078 / ... .

+2


source







All Articles