Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:13:04+00:00 2026-06-13T07:13:04+00:00

I have two UITableViewControllers and I am segueing between them, using a storyboard. In

  • 0

I have two UITableViewControllers and I am segueing between them, using a storyboard.

In prepareForSegue:sender:, the first VC gets an NSArray from a web service and sets the model of the destination VC with the downloaded data. I put the downloading part into a dispatch_queue_t so it will run asynchronously and not block the UI thread. I want to tap a table cell, have the UIActivityIndicatorView start spinning, download the photos, and when the photos are downloaded, stop the spinner and continue with the segue.

In the first UITableViewController I have a prepareForSegue:sender: method:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"SelectPlace"]) {
        NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];

        UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc]
                                            initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        [spinner startAnimating];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:spinner];

        __block NSArray *photos = [[NSMutableArray alloc] init];
        dispatch_queue_t downloadQueue = dispatch_queue_create("flickr download", NULL);
        dispatch_async(downloadQueue, ^{
            photos = [FlickrFetcher photosInPlace:[self.places objectAtIndex:indexPath.row] maxResults:50];
        });
        dispatch_release(downloadQueue);
        [spinner stopAnimating];
        [segue.destinationViewController setPhotos:photos withTitle:[[sender textLabel] text]];
    }

}

Right now it is immediately performing the segue without showing the spinner or waiting for the download to complete.

How can I asynchronously download the data to prepare the destination view without blocking the main thread, but also without immediately segueing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:13:05+00:00Added an answer on June 13, 2026 at 7:13 am

    Have your destination view controller load the data. When the user selects a row in your table, you should immediately segue to the new view controller. This is necessary to keep the user interface snappy. In prepareForSegue, give the destination view controller the data it will need to do the load itself. Then in the viewWillAppear in the destination view controller, load the data asynchronously.

    If you want to keep the destination view controller generic and avoid doing the Flicker photo fetch from the destination view controller, you can set up a protocol that has a method such as getThePhotoData and have a dataSource pointer in your destination view controller that is set to self in prepareForSegue. Then, in viewWillAppear in the destination view controller, call [dataSource getThePhotoData] asynchronously. The flicker photo fetch will take place in the getThePhotoData method which will be implemented in the view controller that triggered the segue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two UITableViewControllers and need to pass the value from the child view
I have a navigation controller that works with two UITableViewControllers. The first UITableViewController shows
I have two UITableViewControllers such that when I click next on the first UITableViewController,
I have a UINavigationController with two UITableViewControllers (A and B). A is displayed first
I have two UITableViewControllers. In the first UITableView, once a user selects a cell,
I have a SplitViewController which has two UITableViewControllers - one master/root one detail. Everything
I have two classes (MVC view model) which inherits from one abstract base class.
I have two UITableViewControllers. One displays a list of names and on tapping any
In my 'Sectioned' UITableView I have two sections, the first one for Attributes like
I have a UINavigationController with two UITableViewControllers pushed onto its stack. Is there any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.