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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:12:42+00:00 2026-05-31T00:12:42+00:00

I have 2 arrays. The first is an array of dictionaries from a JSON

  • 0

I have 2 arrays. The first is an array of dictionaries from a JSON feed. The second is just an array of values I’m using to populate a UITableView.

For each row in the table I need to know whether the value I’m writing to the table cell exists in the first array in any of the dictionaries, so I can set the accessory type appropriately. Is there a simple way of doing this, or would I be better off creating another array of the id values from each dictionary first?

I hope that makes sense, can’t see any other way to explain it 😉

  • 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-31T00:12:43+00:00Added an answer on May 31, 2026 at 12:12 am

    You can use indexesOfObjectsPassingTest: with a block that searches inside the dictionary, but it is suboptimal: you will be re-doing the same search over and over for each cell, which might slow down your app, especially when the user scrolls through your table quickly. You would be a lot better off creating an NSSet with the items as soon as you get the feed, and re-use that when you render your table cells.

    Example:

    Construct NSSet *allIds when you receive your JSON feed, like this:

    allIds = [[NSMutableSet alloc] init]; // NSSet *allIds is declared
             // in the same class as the array from which you get your table cells
    [responseArray enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        [allIds addObjectsFromArray:[arrayOfDictsFromJsonFeed allKeys]];
    }];
    

    When you need to decided whether or not to show your accessory view, do this:

    if ([allIds containsObject:currentId]) {
        // Add accessory view
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays. The first array contains some values while the second array
Suppose I have two arrays like the following: $arr2 = array(array(first, second), array(third, fourth));
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
I have two arrays, each containing strings. The first array is a list of
I have 2 arrays: first array is a bunch of keys. second array is
i have two arrays like this first array Array ( [0228] => Array (
I have two arrays in PHP. The first array ($author_array) is comprised of user_ids
I have two arrays the first one has this structure Parameter Keys array array
I have an array that looks like $numbers = array('first', 'second', 'third'); I want
I have a UITableView that was created from data coming from a mutable 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.