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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:17:06+00:00 2026-06-14T14:17:06+00:00

I populate my app with a plist array with dictionaries. The value for the

  • 0

I populate my app with a plist array with dictionaries. The value for the key “Freshness” in the dictionaries is the name of a bundle image to show the level of freshness in the drink, “level1.png”, “level2.png”, “level3.png”, “level4.png”, “level5.png”, “level6.png” or “level7.png”.

I have added a UIStepper so the user can specify the minimum and maximum freshness of the drink like this:

- (void)viewDidLoad
{
[super viewDidLoad];
minImageView.image = [UIImage imageNamed:@"level1.png"];
maxImageView.image = [UIImage imageNamed:@"level7.png"];
}

- (IBAction)minStepperValueChanged:(id)sender {
double stepperValue = minStepper.value;
minImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"level%.f.png", stepperValue]];
maxStepper.minimumValue = minStepper.value;
minStepper.maximumValue = maxStepper.value;
minLabel.text = [NSString stringWithFormat:@"From level %.f", stepperValue];
}

- (IBAction)maxStepperValueChanged:(id)sender {
double stepperValue = maxStepper.value;
maxImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"level%.f.png", stepperValue]];
maxStepper.minimumValue = minStepper.value;
minStepper.maximumValue = maxStepper.value;
maxLabel.text = [NSString stringWithFormat:@"To level %.f", stepperValue];
}

When searchButtonPressed is called, guess what I want to happen. To add the objects with the correct level of freshness from allObjectsArray to searchResultsArray. Any suggestion for code to filter like this?

I was thinking something like using a mutable array levelsArray with all the level image paths, then remove the objects that goes below minimum or above maximum from levelsArray when searchButtonPressed.

Then add the dictionaries that match one of the remaining objects of this array to searchResultsArray. But I’ve twisted my brain so much on this that I really need some help. Thanks a lot!

EDIT:

I’ve done this for a start:

-(IBAction)searchButtonPressed:(id)sender{

for(double i=otherCriteriasViewController.minStepper.value;i>1;i--) {
    [otherCriteriasViewController.levelsArray removeObject:[NSString stringWithFormat:@"level%.f.png", i-1]];
}

for(double ii=otherCriteriasViewController.maxStepper.value;ii<7;ii++) {
    [otherCriteriasViewController.levelsArray removeObject:[NSString stringWithFormat:@"level%.f.png", ii+1]];
}

and now I want to add all the objects that contain one of the objects of levelsArray.

  • 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-14T14:17:07+00:00Added an answer on June 14, 2026 at 2:17 pm

    If I am understanding correctly, the problem you are trying to solve is filtering an array of dictionaries based on a key that is in each of the dictionaries.

    You can use an NSPredicate to do this.

    Assuming you have an NSArray called “allItems” and that each object in the array is a dictionary containing the key “Freshness”.

    Let’s say you want all the items with a Freshness of 2.

    NSArray *filtered = [allItems filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(Freshness == %@)", @"level2.png"]];
    

    You can also do greater than and less than comparisons using NSPredicates. This is just an equals example.

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

Sidebar

Related Questions

I'm using a plist structured as an array with dictionaries to populate my app.
I'm using a plist with an array of dictionaries to populate a TableView and
I have a working app which has a plist as data container. An array
my app stores players's data and I want to populate a UITableView with it,
So my app is basically a shell with a ContentControl that I populate with
I am working on a children's book app and would like to dynamically populate
I am working on a children's book app and would like to dynamically populate
I have a plist that I want to auto-populate the version number of the
I built a test app. All it does is populate a label on the
I have a list of websites in a plist, when the app loads this

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.