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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:43:48+00:00 2026-06-16T21:43:48+00:00

I’m using a NSMutableDictionary to store some values about some UITableViewCell s, so I’m

  • 0

I’m using a NSMutableDictionary to store some values about some UITableViewCells, so I’m using instances of NSIndexPath as keys. Everything works as expected on iOS 6, but when I run the exact same code in the iOS 5 Simulator, weird things happen. So I printed the contents of the dictionary to the console:

Printing description of heights:
{
    "<UIMutableIndexPath 0x6a8a3d0> 2 indexes [1, 3]" = 100;
    "<UIMutableIndexPath 0x6a8a3d0> 2 indexes [1, 3]" = 100;
    "<UIMutableIndexPath 0x6a8a3d0> 2 indexes [1, 3]" = 100;
}

On iOS 6 it looks like this:

Printing description of heights:
{
    "<UIMutableIndexPath 0x75ca8c0> 2 indexes [0, 1]" = 44;
    "<UIMutableIndexPath 0x75caa70> 2 indexes [0, 0]" = 10;
    "<UIMutableIndexPath 0x75ca500> 2 indexes [1, 0]" = 100;
    "<UIMutableIndexPath 0x717df70> 2 indexes [1, 1]" = 67;
    "<UIMutableIndexPath 0x715a3e0> 2 indexes [1, 2]" = 67;
    "<UIMutableIndexPath 0x717def0> 2 indexes [1, 3]" = 67;
}

Which is how it should be, obviously! Why would the dictionary on iOS 5 store different values for exactly the same key?


Edit: Some code…

The dictionary creating is just

self.heights = [[NSMutableDictionary alloc] init];

I set values using the new subscripting syntax, i.e. like so:

self.heights[indexPath] = minHeight;

(indexPath is a NSIndexPath, minHeight is a NSNumber.)

I set these values dynamically as the delegate requests them:

- (NSNumber *)heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (![indexPath isInTableView:self.tableView])
    {
        @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"indexPath not in tableView" userInfo:nil];
    }

    NSNumber *storedHeight = self.heights[indexPath];
    if (storedHeight != nil)
    {
        return storedHeight;
    }

    NSNumber *minHeight = self.minimumHeights[indexPath];
    self.heights[indexPath] = minHeight;
    return minHeight;
}

The minimumHeights NSDictionary also holds NSNumbers for every indexPath in a table view.

  • 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-16T21:43:49+00:00Added an answer on June 16, 2026 at 9:43 pm

    I remember reading about NSIndexPath methods isEqual: or hash or both changing in iOS6 or just that there was a bug in iOS 5. In any case, it seems you can’t use them as dict keys.

    Try using different keys. Maybe using its description method or a custom string built with the section and row.

    #define idx2key(_ip) [NSString stringWithFormat:@"%d:%d", [_ip section], [_ip row]]
    
    ...
    self.heights[idx2key(indexPath)] = minHeight;
    ...
    

    In old NSIndexPath Apple said:

    NSIndexPath objects are uniqued and shared. If an index path
    containing the specified index or indexes already exists, that object
    is returned instead of a new instance.

    That paragraph doesn’t exist anymore. I guess internal comparison of instances have been changed too.

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

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.