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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:35:08+00:00 2026-05-25T16:35:08+00:00

I need to parse and sort an array with 100+ entries. I have the

  • 0

I need to parse and sort an array with 100+ entries. I have the method for parsing and sorting it below. The catch: I need it the strings stored in the NSMutableArray to be displayed in a tableView immediately when the ViewController that holds the tableView is presented/loaded. If I don’t do this, the UI hangs/freezes when invoking the ViewController. Moving the code into one of my singletons, increases boot time, which I also need to avoid.

I think I have to Queue/Block this code, but I’m not sure how to do it. Any guidance is greatly appreciated!

Here’s the code I have to parse [NSTimeZone knownTimeZones]:

-(void)parseTimeZoneNames {

    for (int i = 0; i < [[NSTimeZone knownTimeZoneNames] count]; i++) {
        NSString *fullName =  [NSString stringWithFormat:@"%@", [[NSTimeZone knownTimeZoneNames] objectAtIndex:i]];
        NSRange firstForwardSlash = [fullName rangeOfString:@"/"];
        NSRange firstNameRange = NSMakeRange(firstForwardSlash.location + 1, ([fullName length] - firstForwardSlash.location - 1));
        NSString *cityName =  [NSString stringWithFormat:@"%@", [fullName substringWithRange:firstNameRange]];

        NSRange secondforwardSlash = [cityName rangeOfString:@"/"];
        if(!secondforwardSlash.length) {

            NSRange secondNameRange = NSMakeRange(secondforwardSlash.location + 1, ([cityName length] - secondforwardSlash.location - 1));
            cityName = [NSString stringWithFormat:@"%@", [cityName substringWithRange:secondNameRange]];

        }

        NSRange underscore = [cityName rangeOfString:@"_"];
        if(!underscore.length) {

            NSRange finalNameRange = NSMakeRange(underscore.location + 1, ([cityName length] - underscore.location - 1));
            cityName = [NSString stringWithFormat:@"%@", [cityName substringWithRange:finalNameRange]];

        }

        [timeZonesArray addObject:cityName];

    }

    [timeZonesArray sortUsingSelector:@selector(compare:)];

}

Here’s the code for presenting it in the same ViewController:

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [[NSTimeZone knownTimeZoneNames] count];
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    cell.textLabel.text = [NSString stringWithFormat:@"%@", [timeZonesArray objectAtIndex:indexPath.row]];

    return cell;

}
  • 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-25T16:35:08+00:00Added an answer on May 25, 2026 at 4:35 pm

    If the code really is too slow then you can pre-sort the data yourself and add it to a plist in your app bundle.

    The time zones in the world aren’t going to change. If they do, we’ve got bigger things to worry about than your app missing a few out.

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

Sidebar

Related Questions

I have some sort of recursive function, but I need to parse a string,
I have multiple text files that represent logging entries which I need to parse
I'm parsing an XML file with LibXML and need to sort the entries by
I need to do a sort of timeout or pause in my method for
I have a rather big number of source files that I need parse and
I need to be able to parse this sort of data in PHP: Acct:
I need to parse some simple binary Files. (The files contains n entries which
For the sake of being able to search and index/sort an array I have
I am creating a template parser and i need to sort the array of
I'm no expert in regex but I need to parse some input I have

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.