Note that there are some explanatory texts on larger screens.

plurals
  1. POUIRefreshControl with two async json downloads to populate UITableView rows and custom header view
    primarykey
    data
    text
    <p>I've got an <code>UITableViewController</code> that fetches it's info from a WS json working fine.</p> <p>Now I need to populate both the table and a Table's header view with two different WS calls, on a <code>UIRefreshControl</code> pull.</p> <pre><code>-(void)refreshView:(UIRefreshControl *)refresh { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ __block NSData *data = [self fetchNewData]; dispatch_async(dispatch_get_main_queue(), ^{ if (data) { [self fetchedData:data]; [self.tableView reloadData]; } else { //show error } [self.refreshControl endRefreshing]; }); }); } -(NSData*)fetchNewData { NSString *api = SINGLE URL; if (api) { NSData* data = [NSData dataWithContentsOfURL: [NSURL URLWithString:api]]; return data; } else { return nil; //alert } } - (void)fetchedData:(NSData *)responseData { //parse out the json data NSError* error = nil; _JSONDict = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&amp;error]; _tableDataRows = [_JSONDict objectForKey:@"tableDataRows"]; } } </code></pre> <p>Finally, <code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath</code> uses <code>_tableDataRows</code> to populate the table.</p> <p>Now, i want to update some labels on the Table's header view, which is a custom view from a ViewController, from a second API URL json, on the same "pull" of the <code>UIRefreshControl</code>, meaning that the loading animation should be on until both jsons are downloaded and parsed. What would be the best way?</p> <p>If you need more info just let me know.. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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