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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:12:42+00:00 2026-06-01T06:12:42+00:00

So I have an NSMutableArray in my app what is filled like so: NSMutableArray

  • 0

So I have an NSMutableArray in my app what is filled like so:

NSMutableArray
--Object 1 (NSMutableDictonary)
  --Value (i) for key (key)
  --Value (i) for key (key)
--Object 2 (NSMutableDictonary)
  --Value (i) for key (key)
  --Value (i) for key (key)

i need to be able to select an object from within the main NSMutableArray by looking for a key what matches a value of one of the NSMutableDictonary‘s keys…

I understand i could run a loop like so to achieve this:

for (NSMutableDictionary *object in arrayObject) {
    if ([[object objectForKey:@"keyToSearch"] integerValue] == keyToCompare) {
        return [object objectForKey:@"keyToReturn"];
    }
}

However my concern is that if this array grows (what it can do) then this will take time to run a search on it..

So I was wondering is there any other way to retrieve the same results but more efficiently?

Thanks

Liam

  • 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-01T06:12:43+00:00Added an answer on June 1, 2026 at 6:12 am

    The search is obviously going to take linear time in the number of dictionaries in the array. You’re not going to get around that by using a different way to search. You could rewrite your search to use an NSPredicate, and it would be slightly shorter but it wouldn’t be any faster.

    If you want to make the search faster, you’ll have to modify your data structure. Or, you could create a NSDictionary to serve as a lookup table, where the keys of the NSDictionary are values of keyToSearch, and the values are the NSMutableDictionaries in your array.

    Still, unless your array gets really really, big the search time will be negligible, and you shouldn’t worry about it.

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

Sidebar

Related Questions

In my app I have a tableview being filled by values from an NSMutableArray.
I have a NSMutableArray filled with NSMutableArray's. I would like to fill my table
In my app I have a tableView filled with contents from a server. To
I have a NSMutableArray in my app which I initiate like this: H-FILE NSMutableArray
I have a NSMutableArray: NSMutableArray *temp = //get list from somewhere. Now there is
I have a NSMutableArray that I need to search for a string and return
Let's say I need to access a web service from an iPhone app. This
I'm using Cocoa Touch to build an iPhone app. I have an NSMutableArray called
I have an NSMutableArray with objects within it and I use the following code
I have a NSMutableArray generated by XMLParser , I would like to sort the

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.