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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:24:19+00:00 2026-06-02T03:24:19+00:00

My application has a UITableViewController which has a list of cells representing names of

  • 0

My application has a UITableViewController which has a list of cells representing names of cities. When a user clicks a cell, the application will change the cell accessoryType to UITableViewCellAccessoryCheckmark and save the text value of the cell (city name) into the persisted store. However, I found that every time I click the cell, it requires at least 10 seconds to actually store the data into the Persistent Store. Any idea why this happens? Instead of saving the data immediately, why it takes so long to persist?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *cityName = [self.citySettingModel nameOfCityAtIndex:indexPath.row OfCountryAtIndex:self.countryIndex];    
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
        cell.accessoryType = UITableViewCellAccessoryNone;
        [[self.citySettingModel worldbikesCoreService] removeCity:cityName];
    }
    else {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
        [[self.citySettingModel worldbikesCoreService] addCity:cityName toCountry:self.countryName];
    }
}

The code for create a City and Country objects are in a different class

- (City *) addCity:(NSString*) cityName toCountry:(NSString*) countryName 
{
    NSManagedObjectContext *context = [self.delegate managedObjectContext];

    Country *country = [self.countryDAO addCountry:countryName inManagedObjectContext:context];

    City *city = [self.cityDAO addCity:cityName inManagedObjectContext:context];

    [country addCitiesObject:city];
    return city;
}

- (City*) addCity:(NSString*) cityName inManagedObjectContext:(NSManagedObjectContext *)context
{
    NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"City"];
    fetchRequest.predicate = [NSPredicate predicateWithFormat:@"cityName = %@", cityName];
    NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"cityName" ascending:YES];
    fetchRequest.sortDescriptors = [NSArray arrayWithObject:sortDescriptor];

    NSError *error;
    NSArray *matches = [context executeFetchRequest:fetchRequest error:&error];

    if (error) NSLog(@"error when retrieving city entities %@", error);

    City *city;

    if (!matches || [matches count] > 1) ;
    else if ([matches count] == 0) {
        city = [NSEntityDescription insertNewObjectForEntityForName:@"City" inManagedObjectContext:context];
        city.cityName = cityName;
    }
    else city = [matches lastObject];

    return city;
}
  • 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-02T03:24:20+00:00Added an answer on June 2, 2026 at 3:24 am

    The really good way to find out what’s taking so long time in Xcode is Time Profiler – it should be your best friend in iOS app developing.

    In Xcode, instead of Run you should hit Test, there select Time Profiler.You can see how much time doe any process takes.

    There are also some tools that let you examine Core Data Fetches.

    Look, what’s taking most time there and update the post. Or, maybe, you couls solve it by yourself then)

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

Sidebar

Related Questions

My application has two node types: a parent node which can hold recursive child
My application has several independent top-level windows, which all have completely different functions/workflows. I
I have an application which has 5 tabs on a TabBarController. For simplicity sake
I created a window application, which has a tabbar controller with four tabbar items.
My application has a view controller that extends UITableViewController . The initialization method looks
Suppose application has multiple apks for different countries. If US user with international roaming
My application has an E-mail address field (textbox) for which I would like to
Our application has a table which stores all transactions records of clients in one
My Application has registered one receiver in Manifest file. What will happen to the
My application has a delete user option. Now in order to check concurrency condition

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.