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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:15:56+00:00 2026-05-27T18:15:56+00:00

In my iPhone application I have an update button which when being pressed adds

  • 0

In my iPhone application I have an update button which when being pressed adds a new subview.This new view covers the whole screen and the table view is not accessible until the whole update action is completed.This is actually the idea but I have the following problem with its realization – the view appears too slowly, it takes 2 or 3 seconds to pop up.

I thought that a possible solution would be to start a new thread and synchronize it but I’m not sure if this will help at all.

- (IBAction) updateButtonPressed: (id)sender {
    self.updateButton.enabled = NO;

    //HERE STARTS THE LOADING VIEW
    LoadingView * loadingView =[LoadingView initializeLoadingView:[self.view.window.subviews objectAtIndex:0]];

    //HERE STARTS THE LOADING VIEW
    [self deleteData];//delete old data
    [self insertNewData];
    [self loadNewData];

    //THE LOADING VIEW IS DISMISSED   
    [loadingView dismissView];

    //THE LOADING VIEW IS DISMISSED   

    self.updateButton.enabled = YES;

}// updateButtonPressed

The view must show instantly after the action begins because otherwise the whole program logic goes to hell.

EDIT:
here is the code for the both methods insertNewData and loadNewData

 - (void) insertNewData
    {
        NSString *urlStr;
        NSError *error;
        NSURLResponse *response;
        if(self.title == @"New York")
        {
            urlStr =[[NSString alloc] initWithFormat: @"http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=New_York,IL"];
        }
        else
            urlStr = [NSString stringWithFormat:@"http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=%@,IL",self.title];

        NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:urlStr]];
        NSData *dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
        xmlControl = [[XMLController alloc] loadXMLbyData:dataReply];
        Forecast *forecast;

        for(ForecastPeriod *newForecast in [xmlControl weatherForecasts])
        {
            forecast = [[Forecast alloc] initWithEntity:[NSEntityDescription entityForName:@"Forecast" inManagedObjectContext:self.managedObjectContext] insertIntoManagedObjectContext:self.managedObjectContext];
            [forecast setValue:newForecast.conditions forKey:@"conditions"];
            [forecast setValue:newForecast.day forKey:@"day"];
            [forecast setValue:newForecast.icon forKey:@"icon"];
            [self addImagesAtSpecificDirectory:newForecast.icon];
            [forecast setValue:newForecast.max forKey:@"max"];
            [forecast setValue:newForecast.min forKey:@"min"];
            [forecast setValue:newForecast.month forKey:@"month"];
            [forecast setValue:newForecast.period forKey:@"period"];
            [forecast setValue:newForecast.weekday forKey:@"weekday"];
            [forecast setValue:newForecast.year forKey:@"year"];
            [forecast setValue:self.title forKey:@"location"];

        }
        if (![self.managedObjectContext save:&error]) {
            NSLog(@"Couldn't save: %@", [error localizedDescription]);        
        }

    }//insertNewData


    - (void) loadNewData 
    {
        AppDelegate *appDelegate = (AppDelegate*) [[UIApplication sharedApplication] delegate];
        NSManagedObjectContext *managedObjectContext = appDelegate. managedObjectContext;
        NSFetchRequest *request = [[NSFetchRequest alloc] init];
        NSEntityDescription *entity = [NSEntityDescription entityForName:@"Forecast" inManagedObjectContext:managedObjectContext];
        [request setEntity:entity];
        NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"period" ascending:YES];
        [request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"location = %@",self.title];
        [request setPredicate:predicate];
        NSError *error;
        NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
        self.items = mutableFetchResults; 
        [self.tableView reloadData];
        [mutableFetchResults release]; 
        [request release];

        //iPad
        if ([[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPad && popOver_ != nil)
        {
            [popOver_ dismissPopoverAnimated:YES];
        }


    }//loadNewData
  • 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-05-27T18:15:57+00:00Added an answer on May 27, 2026 at 6:15 pm
     NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:urlStr]];
     NSData *dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    

    The problem is, that you are performing a synchronous network request on the main thread.

    This means, that the UI will block entirely, until the request is finished.
    You will have to do it asynchronously. You will find plenty of codes on StackOverflow.

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

Sidebar

Related Questions

My new iPhone application have .ipa file size (by Archive) is 2.8 MB, which
In my iPhone application I have a table view. When user taps any row,
hai all, in my iphone application i have a login view with two text
I have created an iPhone application based on an OpenGL view. Now I would
I have kind of Listing application for iPhone application, which always calling a web
I have some query. First of all let's have an iPhone application flow which
I have a UITableView in an iPhone application which I am refreshing (by calling
I'm developing my first iPhone application. I have to update a label with the
I made an iPhone application in which I have to implement myspace integration. I
I have pushed a fourth update(1.4) for my iphone application, but the update is

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.