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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:07:33+00:00 2026-06-10T13:07:33+00:00

I am trying to copy the objects content of a NSDictionary to a NSMutableArray,

  • 0

I am trying to copy the objects content of a NSDictionary to a NSMutableArray, and I am using the following code :

             // Use when fetching binary data
             NSData *responseData = [request responseData];

             // View the data returned - should be ready for parsing.
             resultsDictionary = [responseData objectFromJSONData];
             NSLog(@"ResultsDictionary:%@", resultsDictionary);

             self.OnlineObjects = [[[NSMutableArray alloc] init] autorelease];

             for (NSDictionary * dataDict in resultsDictionary) {
                 [OnlineObjects insertObject:dataDict atIndex:0];
             }

             NSLog(@"OnlineObjects:%@", OnlineObjects);

This is working as i am getting all objects from the Dictionary, but the objects order have been revers, first object is now last …

How can tell the insertObject to add the object at the last index ?

Thanks

  • 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-10T13:07:34+00:00Added an answer on June 10, 2026 at 1:07 pm

    You can use the addObject: method instead.

    To get rid of the hash order problem get allKeys, sort the array and then use the elements as keys to get the objects in proper order.

    Verbose example (for integer keys):

    NSArray *indices = [[resultsDictionary allKeys] sortedArrayUsingComparator:^(id obj1, id obj2) {
        if ( [obj1 intValue] > [obj2 intValue] ) {
            return (NSComparisonResult)NSOrderedDescending;
        }
        if ( [obj1 intValue] < [obj2 intValue] ) {
            return (NSComparisonResult)NSOrderedAscending;
        }
        return (NSComparisonResult)NSOrderedSame;
    }];
    
    for (int i = 0; i < [indices count]; i++) {
        NSDictionary *obj = [resultsDictionary objectForKey:[indices objectAtIndex:i]];
        [OnlineObjects addObject:obj];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to copy files from a directory that is in constant use
I'm trying to copy files to C:\Windows\System32 using cygwin bash. When I copy files
I have two NSMutableArrays: NSMutableArray* currentMessages NSMutableArray* items I am trying to copy the
I am trying to copy the pixels of a bitmap data. but I keep
Related Question: vector <unsigned char> vs string for binary data . My code uses
I'm trying to implement zclip to copy input's content into clipboard. There is 20
I am trying to create a new Core Data entity and copy [some of]
I'm trying to make a deep copy of an object, including a GregorianCalendar instance.
I'm trying to make a copy constructor for an object and one of the
I'm trying to make a copy function and add it to the object's prototype.

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.