2

I want to convert a NSString to int64_t and then print it out using:

NSLog("%lld", i);

Now I can only convert using [str integerValue] which sometimes makes it print out the minus number.

Evan Mulawski
  • 54,662
  • 15
  • 117
  • 144
Bin Chen
  • 61,507
  • 53
  • 142
  • 183

3 Answers3

4

You can use [str longLongValue]

For example:

int64_t i=[@"23570449442514" longLongValue];
CloudyMarble
  • 36,908
  • 70
  • 97
  • 130
Mohamed Adly
  • 210
  • 1
  • 8
4

longLongValue works! [str longLongValue];

user2975399
  • 121
  • 1
  • 1
1

You may use the atoll function.

int64_t i = atoll([str UTF8String]);
Nicolas Bachschmidt
  • 6,475
  • 2
  • 26
  • 36