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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:01:07+00:00 2026-05-26T12:01:07+00:00

I am using a REST based web service to get data. No matter what

  • 0

I am using a REST based web service to get data. No matter what the structure of the JSON document, the NSDictionary gets populated the same way. I want the sorting preserved as the web service returns.

Here is my code:

-(void) getData
{
    NSURL *url = [NSURL URLWithString:@"http://somewebservice"];
    __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setCompletionBlock:^{
        // Use when fetching text data
        NSString *responseString = [request responseString];

        NSDictionary *resultsDictionary = [responseString objectFromJSONString];


            [jokesArray release];
            jokesArray = [resultsDictionary allValues]; //always has the same order. 

            [jokesArray retain];


            [self.tableView reloadData];





        // Use when fetching binary data
  //      NSData *responseData = [request responseData];
    }];
    [request setFailedBlock:^{
        NSError *error = [request error];

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"An error occured" 
                                                        message:[error description]
                                                       delegate:nil 
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];
        [alert show];
        [alert release];
    }];
    [request startAsynchronous];
}
  • 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-26T12:01:07+00:00Added an answer on May 26, 2026 at 12:01 pm

    The entries in an NSDictionary have no inherent order; they are unsorted by definition. The same is true for the array returned by allValues, as the documentation clearly says:

    The order of the values in the array isn’t defined.

    You will need to sort the array afterwards. If you want to keep the same sort order that is in the JSON source, you would have to parse the JSON data manually and retrieve the values from the dictionary one after another. Or, if you know how the JSON data is sorted, just apply the same sorting algorithm to the array returned by allValues.

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

Sidebar

Related Questions

We have a web application providing a service using a simple REST interface (GET/POST
I'm receiving LZMA compressed data via a request to a REST based web service.
I'm writing a REST based web service, and I'm trying to figure out the
I need to build very concurrent web service which will expose REST based API
What is the general approach to exposing a REST based web service that can
I'm attempting to build a REST based web service that provides a currency conversion
HI How do i add data using wcf rest architecture. I dont want to
I'm trying to send data from a client application using jQuery to a REST
I have a simple WCF4 REST service which is working fine when using a
I'm trying to get a simple REST service to work with Spring 3.0 but

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.