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

  • Home
  • SEARCH
  • 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 4036056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:10:33+00:00 2026-05-20T12:10:33+00:00

Spent about a week using stackoverflows search but no luck… Here is what I

  • 0

Spent about a week using stackoverflows search but no luck…

Here is what I have:

1 plist:

<plist version="1.0">
  <array>  
    <dict>
      <key>name</key>
      <string>Name 1</string>
      <key>abrev</key>
      <string>(HGB, ΗbA)</string>
      <key>picture</key>
      <string>first.png</string>
      <key>pictureHeight</key>
      <integer>1686</integer>
    </dict>
    <dict>
      <key>name</key>
      <string>Name 2</string>
      <key>abrev</key>
      <string> </string>
      <key>picture</key>
      <string>second.png</string>
      <key>pictureHeight</key>
      <string>396</string>
    </dict>
    <dict> 
     ...
    <dict>
  </array>
</plist>

The questions is:
How to return values for keys “picture” and “pictureHeight”
knowing the value for the key “name”.

I tried something like this, but failed desperately…

//creating an array that contains the plist

dictArray = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle]  
        pathForResource:@"table1" ofType:@"plist"]];

//creating an array that contains only the vlaues for key "name"

NSMutableArray *temp = [dictArray valueForKey:@"name"];

//searchedData - an NSMutableArray containing the "name" values that  
//the user searched using the searchbar

for (i=0; i<[searchedData count]; ++i) 
{
    if ([searchedData containsObject:[temp objectAtIndex:i]]) 
    {
        [temp removeObjectAtIndex:i];
    }
}

At the end I have an array of values for key “name” and I need to get the “picture” and “pictureHeight” to push all of this information to next view controller…

I’m looking for any fresh ideas (or maybe tutorials), because I’m not getting too far with mine…

  • 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-20T12:10:34+00:00Added an answer on May 20, 2026 at 12:10 pm

    Use a NSPredicate and NSArray’s -filteredArrayUsingPredicate: method to select the dictionaries in the array where the value for key ‘name’ matches whatever you’re looking for. Then you can query the resulting dictionary or dictionaries the usual way, i.e. using objectForKey:.

    NSPredicate is very powerful and worth the time it’ll take you to learn to use it, but it does require some study. If you want something that’s simpler to implement but less elegant, simply iterate over the array yourself:

    NSMutableArray *matches = [NSMutableArray array];
    for (NSDictionary *d in searchedData) {
        if ([name isEqualToString: [d objectForKey:@"name"]]) {
            [matches addObject:d];
        }
    }
    

    Again, you end up with an array containing the dictionaries whose ‘name’ matches the name you’re looking for, and you can get their other attributes the usual way.

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

Sidebar

Related Questions

I have spent quite a few hours reading and learning about LINQ to XML , but
I am new to git but have spent a good deal of time reading
About a month a go I spent almost an entire week trying to figure
http://support.microsoft.com/kb/953102 We spent about 50 hours during Christmas holiday to identify this problem, causing
How would I go about adding the Spent Time as a column to be
I spent ages learning VML and creating charts for a website once, but since
I just spent a whole week tracking down and whacking memory leaks over the
We have a database that contains information about time booked to projects. We have
I am using an open source .Net library which uses MSMQ underneath. After about
I've spent about 10 hours trying to find this bug that was causing my

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.