0

In this UITable methode I get the number of sections in my table:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [[self.myMutableDictonary allKeys] count];
}

Everything works fine on 64 Bit devices and simulator. But on older devices/simulators my table shows 0 sections or 1 section (random). However there should be 15 sections like in the 64 Bit Versions.

I know it has to be something with 64/32 Bit, but I have no idea what the reason is.

user2415476
  • 211
  • 1
  • 15
  • Most likely that's just coincidence. I don't see how that could be caused by differences in 32/64 bit architectures. How do you create myMutableDictionary? Btw. `allKeys` is unordered. It's not a good idea to use that as dataSource. – Matthias Bauch Dec 30 '14 at 20:21
  • Yeah, there's nothing in the above code that would be sensitive to integer size. – Hot Licks Dec 30 '14 at 20:22

1 Answers1

0

Thank you for your help. You were right, it has nothing to do with count.

I compared NSDates in my app with the '<' sign. Apparently this is possible with 64 Bit devices and provides good results. However with 32 Bit devices it provides random results.

Now I use the - (NSComparisonResult)compare:(NSDate *)anotherDate methode. Everything works fine

user2415476
  • 211
  • 1
  • 15
  • I would revisit the logic of comparing `NSDate` objects with `<` on 64 bit architectures. I would start [here](http://stackoverflow.com/a/2293878/620197) – Mike D Dec 30 '14 at 20:49
  • You can't (validly) compare NSDate objects with `<` or `==` or such. When you do that you're comparing object addresses, and even if two NSDate objects are identical they likely have different addresses. (It *might* work on a 64-bit system *sometimes* because NSDate and NSNumber objects are *sometimes* optimized into single 64-bit quantities. But you can't bet on this, even from one execution of your code to the next.) – Hot Licks Dec 30 '14 at 23:26
  • (You should NEVER use those operators to compare objects.) – Hot Licks Dec 30 '14 at 23:27