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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:54:23+00:00 2026-05-28T22:54:23+00:00

I have an NSArray storing NSDictionaries. Each dictionary has two keys; a name and

  • 0

I have an NSArray storing NSDictionaries. Each dictionary has two keys; a name and a sub-array containing ‘items’.

I want to check if one of these dictionaries still remains in the NSArray after a certain operation. Before the operation, I store a pointer called ‘orginalDictionary’ to the dictionary I am interested in. I then perform my operation (which removes one of the ‘items’ from the sub-array inside that dictionary). After the operation, I thought I could check if the Dictionary itself (not the removed item) still exists, using

if ([arrayOfDictionaries containsObject:originalDictionary]) {...

but it’s not working as anticipated. Even though the Array still contains the original dictionary (albeit with a modified sub-array inside it), the call returns that the array no longer contains that dictionary.

Can that be right? If an item in an array changes, does containsObject no longer recognize it as the same object? Or is something else going on here?

EDIT
I’m starting to think that the way in which my array is populated is the root cause. The array of dictionaries is created from one or more other arrays, depending on some settings. These arrays are themselves populated using a fetch request, which created the dictionaries based on the fetched objects. So, when there is a change to some data (or perhaps even if the fetch is fired simply by requesting the return result of the array), this is going to be rebuild the returned array, and the dictionaries inside will be new items. Does this sound about right? If so, I suppose I have no option but to store a self-managed unique key?

  • 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-28T22:54:23+00:00Added an answer on May 28, 2026 at 10:54 pm

    containsObject: determines whether an object representing the same value is in the array, this is the same test that isEqual: and indexOfObject: use. E.g. two completely different dictionaries which contain the same key/value pairs will compare equal as they both represent the same value – just as two integer variables compare equal if they contain the same integer value.

    The method indexOfObjectIdenticalTo: looks for whether the object is present in the array.

    However that doesn’t directly solve your problem. If you actually have an NSMutableArray which contains NSMutableDictionarys and you keep a reference to the NSMutableDictionary you’re checking for then value or object comparison should work…

    Either use the debugger to track the actual references (addresses/pointers), or dump them to the console using NSLog() and the %p format (e.g. NSLog(@"Tracked dict: %p", originalDictionary)).

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

Sidebar

Related Questions

I have an NSArray I want to make changes to a dictionary stored in
I have an NSArray containing several NSDictionaries . I have an NSString containing an
Possible duplicate : comparing-two-arrays I have two NSArray and I'd like to create a
I have a bunch of NSDictionaries thats stored in an NSArray. The dictionaries store
I have an NSArray of strings. I have to place each string in a
I have an NSArray of Strings and what I want to do is create
I have an NSArray formed with objects of a custom class. The class has
I have an NSArray of strings and I want to add a certain amount
I have an NSArray consisting of NSNumbers and I want to convert this to
First of all Merry Christmas to everyone!!! Currently I have a NSArray that has

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.