Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p><strong>delegate</strong> <em>noun |ˈdeligit|</em></p> <p>A person sent or authorized to represent others, in particular an elected representative sent to a conference.</p> </blockquote> <p>A delegate in the Cocoa Touch frameworks such as Foundation or UIKit is a separate object instance that is entrusted to listen in to, and optionally decide behaviours on behalf of the delegator.</p> <p>Take the example of <code>UIWebView</code>. The web view can entrust responsibility onto one delegate as long as that instance conforms to the <code>UIWebViewDelegate</code> protocol, that is <em>promises to behave as the web view expects a delegate to behave</em>.</p> <p>The delegate gets called from time to time. Embedded in the delegate method names is information about what the call is about.</p> <ul> <li><code>webView:</code><strong><code>should</code></strong><code>StartLoadWithRequest:navigationType:</code> - Tells the delegate that the webview wants to load a request, and ask the delegate if it <strong>should</strong> do so.</li> <li><code>webView:</code><strong><code>will</code></strong><code>StartLoad:</code> - Tells the delegate that the web view <strong>will</strong> start loading a page, and it is too late to do anything <em>(This is a hypothetical method that is not actually available, I use it as a consistent example)</em>.</li> <li><code>webView:</code><strong><code>did</code></strong><code>FinishLoad:</code> - Tells the delegate that the web view <strong>did</strong> load a page and it is now finished.</li> </ul> <p>The value of using delegation is that you do not need to sub-class <code>UIWebView</code> in order to tweak how it behaves. One objkect can also serve as delegate to many different webviews, or even serve as delegate to many different kinds of classes.</p> <p>A normal <code>UIViewController</code> subclass probably conforms to many delegate protocols, for example <code>UITableViewDelegate</code> to respond to selections in a table, <code>UIActionSheetDelegate</code> to respond to selection from an action sheet, etc.</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