-2

I have a string as

NSString *milliSeconds=@"1413808458821";

I tried the following to convert it to number, but None of them are giving correct value.

NSInteger number = [milliSeconds intValue];

NSInteger number = [milliSeconds integerValue];

NSInteger number = [milliSeconds longLongValue];

Please help me. Thanks in advance.

Ashok
  • 5,585
  • 5
  • 52
  • 80

1 Answers1

3

This is probably because you are running this code on a 32bit architecture, thus NSInteger is always an int and the number you're trying to convert is too big for this data type.

Try manually specifying the type to long long.

Dominik Hadl
  • 3,609
  • 3
  • 24
  • 58