I just ran this code in CodeRunner
size_t shortSize = sizeof(short); size_t intSize = sizeof(int); short short123000 = 123000; int int123000 = 123000; NSString *format = @"\nshortSize => %d\n" @"int Size => %d\n" @"short with 123000 => %d\n" @"int with 123000 => %d"; NSLog(format, shortSize, intSize, short123000, int123000);
that leads to:
shortSize => 2 int Size => 4 short with 123000 => -8072 int with 123000 => 123000
NB . The size is in bytes and 8 bits per byte, so 2 * 8 = 16 bits and 4 * 8 = 32 bits.
I had problems with some of the applications I'm working on. It would seem that CoreData has become a little more stringent in enforcing its types. I was caught by this, but I had to be very vigilant about what I would do if Apple changed its API so that it did not behave as expected that people would complain, but when the API was changed to do the fact that he is advertised in the first place is simply unsuccessful and is likely to catch people.
As you can see, this is a simple integer overflow, so if you know the range you work in, you can easily fix this.
source share