Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you are returning an object created by a method that does not start with alloc, copy, mutableCopy, convention says you should autorelease it.</p> <p>Autorelease means that it will be release in the future. If the caller of the method needs it to stick around, then they will retain it.</p> <p>Read the memory management guide:</p> <p><a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html" rel="nofollow">http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html</a></p> <p>Here's the rules:</p> <p><em><strong>1 &amp; 3 apply to that method. 2 applies to a calling class that may need to hold it.</em></strong></p> <p><strong>1 - You own any object you create</strong> You create an object using a method whose name begins with “alloc”, “new”, “copy”, or “mutableCopy” (for example, alloc, newObject, or mutableCopy).</p> <p><strong>2 - You can take ownership of an object using retain</strong> A received object is normally guaranteed to remain valid within the method it was received in, and that method may also safely return the object to its invoker. You use retain in two situations: (1) In the implementation of an accessor method or an init method, to take ownership of an object you want to store as a property value; and (2) To prevent an object from being invalidated as a side-effect of some other operation (as explained in “Avoid Causing Deallocation of Objects You’re Using”).</p> <p><strong>3 - When you no longer need it, you must relinquish ownership of an object you own</strong> You relinquish ownership of an object by sending it a release message or an autorelease message. In Cocoa terminology, relinquishing ownership of an object is therefore typically referred to as “releasing” an object.</p> <p><strong>4 - You must not relinquish ownership of an object you do not own</strong> This is just corollary of the previous policy rules, stated explicitly.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload