Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you make your view controller implement the <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/NSXMLParserDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSXMLParserDelegate" rel="nofollow noreferrer"><code>NSXMLParserDelegate</code></a> protocol, and set the <code>NSXMLParser</code> instance's delegate property to your view controller, your view controller will know when the parser <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/NSXMLParserDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSXMLParserDelegate/parser:didEndElement:namespaceURI:qualifiedName:" rel="nofollow noreferrer">parses stuff</a> and <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/NSXMLParserDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSXMLParserDelegate/parserDidEndDocument:" rel="nofollow noreferrer">finishes its work</a>. In other words, the view controller can consume a populated data model, once the parser subclass tells the delegate it is done.</p> <p>As an aside, <a href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhone101/Articles/01_Overview.html#//apple_ref/doc/uid/TP40007514-CH10-SW5" rel="nofollow noreferrer">delegation</a> is one of a few design patterns that OS X applications (and, specifically, Apple APIs) make heavy use of. As you do iPhone development, you'll likely find and make use of delegates everywhere.</p> <p>If you don't want to use delegates, another option is to implement an observer pattern, issuing <a href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSNotification_Class/Reference/Reference.html" rel="nofollow noreferrer">notifications</a> from the <code>NSNotificationCenter</code> to observers, which call their selectors (methods) when they hear a notification. The advantage of notifications over delegates is that you can have lots of objects listen for notifications, whereas only one object can generally be a delegate at a given time.</p>
 

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