Saturday, 15 September 2012

ios - How to cast NSNumber to long long int correctly? -



ios - How to cast NSNumber to long long int correctly? -

im trying cast nsnumber long long int i'm getting unexpected values.. doing wrong?

nsnumber *number = [[nsnumber alloc] initwithint:60]; if ([self istimeover:number]) { [self sendpushtest]; } -(bool)istimeover: (nsnumber*) interval { long long int theinterval = (long long int)interval; nslog(@"the interval %lld",theinterval); // -5764607523034233918 here. }

use -longlongvalue since long long int , long long same.

long long int theinterval = [interval longlongvalue];

you should never seek casting nsnumbers primitive types (doing result in garbage number got). take @ documentation more info.

ios int nsnumber

No comments:

Post a Comment