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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:14:48+00:00 2026-05-28T03:14:48+00:00

here is my question: I have a plist with some objects in it. These

  • 0

here is my question: I have a plist with some objects in it. These objects have some keys like “age”, “sex” ,”person” and etc. If values of these keys are suitable for my if statement, I add this object in my array.

Then, when my array is finally full of some suitable objects I would like to check one more key of every object – “minimumCost” which type is NSNumber and then sort objects from the cheapest to the most expensive objects. And I don’t know how to do that. Could you give me some ideas, code or solutions please?

Here is my code:

-(NSMutableArray*)creatingList:(NSMutableArray *)array
    {
        NSDictionary  *mainDictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"gifts" ofType:@"txt"]];

        //---enumerate through the dictionary objects inside the rootDictionary
        NSEnumerator *enumerator = [mainDictionary objectEnumerator];
        id returnValue;

        while ((returnValue = [enumerator nextObject])) 
        {
          // Big if statement comes

          if (([[returnValue valueForKey:@"sex"]isEqualToNumber:[NSNumber numberWithInt:sex]] ||
                [[returnValue valueForKey:@"sex"]isEqualToNumber:[NSNumber numberWithInt:2]]) && 
                [[returnValue valueForKey:@"person"]isEqualToString:person] &&
                age >= [[returnValue valueForKey:@"minAge"] intValue] &&
                age <= [[returnValue valueForKey:@"maxAge"] intValue])

            {  
                [array addObject:[returnValue valueForKey:@"name"]];                  
            }
        }

        for (int n = 0; n < [array count];n++)
        {
           //   WHAT CODE SHOULD BE HERE ?
        }

   return array;
}

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-05-28T03:14:49+00:00Added an answer on May 28, 2026 at 3:14 am

    You can use the built-in NSArray sorting methods to accomplish this, rather than rolling your own.

    See more here: http://www.cocoanetics.com/2009/03/nsarray-sorting-using-selectors/

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

Sidebar

Related Questions

Here is a question that I have had for some time but never actually
I have an other active question HERE regarding some hopeless memory issues that possibly
Hopefully a quick python question here... import plistlib pl = plistlib.readPlist('/Users/name/Documents/some.plist') print(pl[0]['keyA'] , pl[0]['keyD']
Here is my question : I have a database (mysql) like this : id0
Following up on my question here , I have 22 plist files that I'd
I have a question here regarding iPhone app submission. I have a free application
here is a good question: I have an application compiled for iPhone OS 2.21.
C# question here.. I have a UTF-8 string that is being interpreted by a
Just a quick question here. I have a program in which I need to
I have a simple unit test case (extensive question here ) on a configuration

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.