I just need verify that the way i think here is correct, say that i have:
long someValue;
And that i need the user of the program to input a value to this variable using scanf or by some other means if it's a GUI application, now because long could be treated as a 32bit or as a 64bit (depending on machine/os) i should treat it like its a 32bit storage to get it to work on both consistently.
I should check that the someValue is not larger than maximum range by: (Doing this because if it's archived on a machine that treats long as 64 bit we loose data when using the encodeInt32:forKey: method, also if its a machine that treats long as 32 bit we can't store larger values than INT32_MAX)
if (someValue > INT32_MAX) NSLog(@"To large value inputted!");
if i had someValue unsigned, INT32_MAX would be replaced with UINT32_MAX.
And lastly if i wanted to archive this value, i would use the encodeInt32:forKey: method and unarchive it with decodeInt32ForKey:.
Using all this i would have consistent behavior on both 32 and 64 bit machines/OS's and the file could be archived on one and unarchived on other without loss of data. I could also declare someValue to be int32_t instead to save some memory in the program since the value is stored as 64bit but only half is used on those machines that tread long as a 64 bit.