How do I correctly inject NSNumber into a long long int?

im trying to cast NSNumber on long long int but i am getting unexpected values. What am I 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); // I get -5764607523034233918 here.



source to share

1 answer

Use -longLongValue

as long long int

and long long


long long int theInterval = [interval longLongValue];


You should never try to simply differentiate NSNumber

to primitive types (this will end up giving you a garbage number). Have a look at the documentation for more information.



All Articles