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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:15:35+00:00 2026-05-27T01:15:35+00:00

plist1 is an array of 40 dictionaries, with 4 strings each. plist2 is also

  • 0

plist1 is an array of 40 dictionaries, with 4 strings each.
plist2 is also an array, but of 120 dictionaries with 2 strings each.

If I list all the teams in a hockey league in a table (populated from a certain key in plist1), say I choose the fifth one down. This pushes a new table. The 120 dictionaries in plist2 have two strings – each has one for a year of the league’s history in order, and one for who won the championship that year. I want this second table to list only the years for which the the dictionary’s second key is the same team name that was just selected in the first table, plist1. So, when I select team “5” from the first table, I’d expect to see only the years that team “5” won in the second table. The idea is that all the years will be present in plist2, but the irrelevant ones will be blocked in the actual table on-the-go.

How can I say “if the user selected team X, then show the years just for team X, not all the years.”

Thank you!

  • 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-27T01:15:35+00:00Added an answer on May 27, 2026 at 1:15 am

    Actually you can do this kind of filtering quite nicely using NSPredicate:

    NSDictionary *testA = [NSDictionary dictionaryWithObjectsAndKeys:@"valA", @"key1", @"1", @"key2", nil];
    NSDictionary *testB = [NSDictionary dictionaryWithObjectsAndKeys:@"valB", @"key1", @"2", @"key2", nil];
    NSDictionary *testC = [NSDictionary dictionaryWithObjectsAndKeys:@"valC", @"key1", @"1", @"key2", nil];
    NSDictionary *testD = [NSDictionary dictionaryWithObjectsAndKeys:@"valD", @"key1", @"3", @"key2", nil];
    
    NSArray *testArr = [NSArray arrayWithObjects:testA, testB, testC, testD, nil];
    
    NSPredicate *pred = [NSPredicate predicateWithFormat:@"key2 == %@", @"1"];
    NSArray *testFilter = [testArr filteredArrayUsingPredicate:pred];
    
    NSLog(@"%@", testFilter);
    

    This setup creates 4 dictionaries and an array of them. The filter expression now searches for all contained objects where key2 is equal to 1, which should be testA and testC. And voila theres the output:

    2011-11-24 18:57:07.822 testapp[9977:f803] (
            {
            key1 = valA;
            key2 = 1;
        },
            {
            key1 = valC;
            key2 = 1;
        }
    )
    

    This way you can create a predicate to filter by your team name and create a filtered version of your array. Generally this works on all kinds of object that support key-value coding (which NSDictionary does, further info on that: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/BasicPrinciples.html#//apple_ref/doc/uid/20002170)

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

Sidebar

Related Questions

I have a plist file which is an array of dictionaries. Where each dictionary
I have a plist (array of dictionaries) with 20 items, each of the 20
I have an array of dictionaries loaded from a plist (below) called arrayHistory. <plist
I'm trying to display data from a plist that is an array of dictionaries:
I have a plist file which contains an array of dictionaries. Here is one
I'm replacing an array of NSMutableDictionary objects with an array of custom objects. Each
I've been using the following to create an array from a plist of dictionaries:
I have an array of dictionaries in an iOS .plist structured similar to the
I have a property list ( Data.plist ) that contains an array of two
In a plist I have several dictionaries (events, eg. soccer matches) in an array

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.