I have a NSNumber
and when I try to do basic arithmetic it fails.
NSNumber *contentExpirationInDays = [NSNumber numberWithInt: 1];
When I try to do a basic multiplication to convert to seconds it gives me crazy numbers:
NSTimeInterval contentExpirationInSecs = [contentExpirationInDays intValue] * 24 * 60 * 60;
Note: The next bit is now irrelevant as explained in some answers:
When I run the following commands in the console I get the following results:
(lldb) po [contentExpirationInDays intValue]
1
(lldb) po [contentExpirationInDays intValue] * 2
-148319360
UPDATE
Thanks for the information regarding po vs p. I didn't know that detail...
So here is the real problem that I am experiencing:
NSNumber *contentExpirationInDays = [[NSNumber numberWithInt:1];
NSTimeInterval contentExpiration = ([contentExpirationInDays intValue] * 24 * 60 * 60);
myObj.expirationDate = [[NSDate date] dateByAddingTimeInterval:contentExpiration];
obj.expirationDate
usually ends up with many years in the future or many years in the past instead of one day ahead of today.