5

I cannot find the right format specifier for int64_t

int64_t var;

[NSString stringWithFormat:@"value is: %?? ",var];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Nicolas Manzini
  • 8,379
  • 6
  • 63
  • 81
  • http://stackoverflow.com/questions/13604137/definition-of-int64-t and http://stackoverflow.com/questions/2985008/how-should-i-declare-a-long-in-objective-c-is-nsinteger-appropriate – iPatel May 07 '14 at 14:01
  • I looked at this answer but I didn't find a solution especially when it comes to 32bits 64 bits platform compatibility. – Nicolas Manzini May 07 '14 at 14:31
  • 4
    @NicolasManzini: You can directly use the first answer to that question: `[NSString stringWithFormat:@"value is: %" PRId64 "", var]` works on all platforms. – Martin R May 07 '14 at 14:46
  • should I close or delete this post? – Nicolas Manzini May 07 '14 at 15:45

1 Answers1

13

Try:

int64_t var;    
[NSString stringWithFormat:@"value is: %lld",var];
tiguero
  • 11,477
  • 5
  • 43
  • 61
  • 2
    Alternatively boxing the number as an object is quite nice i.e. `[NSString stringWithFormat:@"value is: %@",@(var)]` – James Snook May 07 '14 at 15:15