Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The memory management rules of Objective-C define the behaviour, so it doesn't need to expressly document that it retains the modal view controller. If an object needs to keep a passed object around after the method has finished executing, it <em>will</em> retain the object <em>unless otherwise specified</em>.</p> <p>So in this case, you should just pass the view controller to <code>presentModalViewController:animated:</code> and then release it (or use autorelease).</p> <p>This applies everywhere in Objective-C. If an object takes another object as method input, you <em>never</em> have to retain that object on its behalf.</p> <p>As requested in the comments, if you read Apple's <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/20000994-BAJHFBGH" rel="noreferrer">documentation on memory management</a>, then you'll find the <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmObjectOwnership.html#//apple_ref/doc/uid/20000043-1044135" rel="noreferrer">section on Weak References</a>, which states:</p> <blockquote> <p><strong>Important</strong>: In Cocoa, references to table data sources, outline view items, notification observers, and delegates are all considered weak (for example, an NSTableView object does not retain its data source and the NSApplication object does not retain its delegate). The documentation <em>only describes exceptions to this convention.</em></p> </blockquote> <p>This actually states that this is a convention in itself and that exceptions will be stated in the documentation, however, going to the documentation for <code>NSTableView</code> and looking at the <code>setDataSource:</code> method, we see:</p> <blockquote> <p><strong>Discussion</strong> In a managed memory environment, the receiver maintains a weak reference to the data source (that is, it does not retain the data source, see Communicating With Objects). After setting the data source, this method invokes tile.</p> <p>This method raises an NSInternalInconsistencyException if anObject doesn’t respond to either numberOfRowsInTableView: or tableView:objectValueForTableColumn:row:.</p> </blockquote>
 

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