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 8830957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:12:26+00:00 2026-06-14T08:12:26+00:00

I have a TableViewController with a button that triggers an [NSURLConnection sendAsynchronousRequest…] event, and

  • 0

I have a TableViewController with a button that triggers an [NSURLConnection sendAsynchronousRequest...] event, and also loads a modal segue through performSegueWithIdentifier:sender: which targets a small view controller. The purpose of this overlay view controller is to show a loading graphic and to prevent user interaction while the data is sent through the NSURLConnection.

In the completion block of the NSURLConnection, I call a method which removes the data in the TableViewController (its just a batch listing), and then calls dismissViewControllerAnimated:completion: on the overlay view controller.

Everything works except for dismissing the overlay view controller, which throws a warning in the debugger which says:
“Warning: Attempt to dismiss from view controller while a presentation or dismiss is in progress!”

I have found various questions and answers about this error, particularly about using the performSelector:object:withDelay methods, but so far nothing has worked.

This is particularly annoying because I use a similar process in another area of the app, except that the dismissViewController is called from selecting a UITableViewCell, and this works fine…

The relevant bits of my code are shown below:

#import "ViewBatch.h"

@interface ViewBatch ()
@property (strong, nonatomic) LoadingOverlayViewController *loadingOverlay;
@end

@implementation ViewBatch
@synthesize loadingOverlay;

....

- (IBAction)exportBatch:(id)sender
{
    if ([productArray count] > 0) {
        [self performSegueWithIdentifier:@"loadingSegue" sender:self];
        [self processData];
    }
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"loadingSegue"]) {

        loadingOverlay = segue.destinationViewController;
    }
}

- (void)processData
{

    // Code to create a file and NSURLRequest...
    // ....

    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    [NSURLConnection sendAsynchronousRequest:urlRequest
                                       queue:queue
                           completionHandler:^(NSURLResponse *response, NSData *responseData, NSError *error) {
                               if ([responseData length] > 0 && error == nil)
                               {
                                   // Not used for this request yet...
                               }
                               else if ([responseData length] == 0 && error == nil)
                               {
                                   // Success...
                                   [self didSendData];
                               }
                               else if (error != nil)
                               {
                                   // Connection error...
                                   NSLog(@"Error: %@", error);
                               }
                          }];
}

- (void)didSendData
{
    // Reset the batch...

    [productArray removeAllObjects];
    [self.tableView reloadData];

    [loadingOverlay dismissViewControllerAnimated:YES completion:NULL];
}

And the loading view controller is just:

#import <UIKit/UIKit.h>

@interface LoadingOverlayViewController : UIViewController

@property (weak, nonatomic) IBOutlet UILabel *statusLabel;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;

@end

....

....

#import "LoadingOverlayViewController.h"

@interface LoadingOverlayViewController ()
@end

@implementation LoadingOverlayViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.activityIndicator startAnimating];
}

@end
  • 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-14T08:12:27+00:00Added an answer on June 14, 2026 at 8:12 am

    I’m not sure about the exact cause of the problem, but here are some observations about your code.

    • You do not need an overlay in order to prevent user interaction. Simply turn off user interaction with -NSApplication beginIgnoringInteractionEvents.

    • You do not need an entire view controller in order to show an overlay view. Just show the view. For example I often place a large UIActivityIndicatorView in the middle of my view while an NSURLConnection is happening.

    • You do not need an NSOperationQueue in order to use NSURLConnection asynchronously. It is already asynchronous. Just create the NSURLConnection and wait for the delegate messages to arrive. As it is, you are bolluxing yourself because you are setting up a secondary queue, the message arrives on that queue, and you call didSendData which calls reloadData on the table – in the background, which is illegal. If you did this the normal way, your delegate messages would arrive on the main thread which is exactly what you want.

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

Sidebar

Related Questions

Maybe a FAQ at this website. I have a TableViewController that holds a form.
Okay so i have done a tutorial that has me populating a TableViewController from
I have two View Controllers: TableViewController (which is used as a modal view controller)
I have a fairly simple TableViewController listing items that can be checked as they
i have a button that i create in my CustomCell. - (IBAction)onoffBtn:(id)sender { UIButton
I have a main view controller which loads a tableviewcontroller when you press a
Here is my situation. I have ViewController class A with a button that goes
I have some TableViewController with static Cells and some TextFields. A few Days ago,
I have an iPhone app with a tableviewcontroller. When you click a certain cell
I have problem with TableView its empty. In (.h) file: @interface TableViewController : UITableViewController{

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.