Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The function after the caret (^) is a "block". <a href="https://stackoverflow.com/questions/3499186/what-does-this-syntax-mean-in-objective-c">See this post.</a></p> <p>The localSearch object will invoke the block (anonymous function) defined below when it needs to (when it has completed). This is like a delegate assigned to work off the result of the operation, but without requiring you to define a new function to receive the callback. The calling class is the delegate (i.e. self refers to the caller in the function).</p> <p>I added some comments for specific details.</p> <pre><code> (MKLocalSearchResponse *response, NSError *error) { // If there is not an error if (!error) { int i = 0; do { MKMapItem *mapItem = [response.mapItems objectAtIndex:i]; // The map items found are added to a mapItems NSMutableArray (presumed) that is // owned by the original caller of this function. [self.mapItems addObject:mapItem]; i++; } while (i &lt; response.mapItems.count); // Using the Observer design pattern here. Some other object must register for the // @"Address Found" message. If any were found, it will be called. [[NSNotificationCenter defaultCenter] postNotificationName:@"Address Found" object:self]; } else { // Using the notification center to announce "not found". I am not sure if this is correct, // since this would be the response if there was an error, and not found is not necessarily // the same as an error occurring. [[NSNotificationCenter defaultCenter] postNotificationName:@"Not Found" object:self]; } </code></pre> <p>Was this helpful?</p> <p>Is there a specific problem you were trying to address?</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. VO
      singulars
      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