Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is what delegates are for. The FetchTideData class should define a delegate protocol with a method that passes the data to its delegate. That method should be called in the completion block of your fetch. The view controller where you want to use this data, should alloc int an instance of this class, and set itself as the delegate.</p> <p>In the FetchTideData.h file you would have something like this:</p> <pre><code>@protocol DownloadHelperDelegate &lt;NSObject&gt; -(void)fetchDidFinishWithResult:(id) result; @end @interface FetchTideData : NSObject @property (weak,nonatomic) id &lt;DownloadHelperDelegate&gt; delegate; </code></pre> <p>Then, in your getJSON method, you would add a line to call the delegate method:</p> <pre><code>-(void)getJSON { NSString *locationQueryURL = @"http://api.wunderground.com/api/xxxx/tide/geolookup/q/43.5263,-70.4975.json"; [JSONHTTPClient getJSONFromURLWithString:locationQueryURL completion:^(NSDictionary *json, JSONModelError *err) { NSLog(@"Got JSON from web: %@", json); [self.delegate fetchDidFinishWithResult:json]; }]; } </code></pre> <p>In the view controller's viewDidLoad method (assuming you want to start a fetch right away), you would instantiate an instance of FetchTideData, set yourself as delegate, and call getJSON:</p> <pre><code>-(void)viewDidLoad { FetchTideData *fetcher = [FetchTideData new]; fetcher.delegate = self; [fetcher getJSON]; } </code></pre> <p>Finally, you would implement the delegate method, which will be called by fetcher when it completes its fetch:</p> <pre><code>-(void)fetchDidFinishWithResult:(id) result { // do whatever you want here with the result } </code></pre>
    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.
 

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