Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save searls/337818 to your computer and use it in GitHub Desktop.
Save searls/337818 to your computer and use it in GitHub Desktop.
Looks like the simulator and device evaluate parameters in a different order
NSUInteger uid = 0;
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
[dictionary setObject:[NSNumber numberWithInt:uid++] forKey:[NSNumber numberWithInt:uid]];
NSNumber *result = [dictionary objectForKey:[NSNumber numberWithInt:1]];
NSLog(@"Result: %@",result);
//device: 2010-03-19 12:51:31.938 Sandbox[568:207] Result: 0
//simulator: 2010-03-19 12:50:24.281 Sandbox[6594:207] Result: (null)
uid = 0;
dictionary = [NSMutableDictionary dictionary];
[dictionary setObject:[NSNumber numberWithInt:++uid] forKey:[NSNumber numberWithInt:uid]];
result = [dictionary objectForKey:[NSNumber numberWithInt:1]];
NSLog(@"Result: %@",result);
//device: 2010-03-19 12:52:54.911 Sandbox[583:207] Result: 1
//simulator: 2010-03-19 12:53:19.826 Sandbox[6829:207] Result: (null)
uid = 0;
dictionary = [NSMutableDictionary dictionary];
uid++;
[dictionary setObject:[NSNumber numberWithInt:uid] forKey:[NSNumber numberWithInt:uid]];
result = [dictionary objectForKey:[NSNumber numberWithInt:1]];
NSLog(@"Result: %@",result);
//device: 2010-03-19 12:55:30.358 Sandbox[598:207] Result: 1
//simulator: 2010-03-19 12:54:29.667 Sandbox[6937:207] Result: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment