NSLog and datatype specifiers


/ Published in: Objective C
Save to your folder(s)

%@ Object

%d, %i signed int
%u unsigned int
%f float/double
%1.2f to controll number of decimals
%x, %X hexadecimal int
%o octal int
%zu size_t
%p pointer
%e float/double (in scientific notation)
%g float/double (as %f or %e, depending on value)
%s C string (bytes)
%S C string (unichar)
%.*s Pascal string (requires two arguments, pass pstr[0] as the first, pstr+1 as the second)
%c character
%C unichar

%lld long long
%llu unsigned long long
%Lf long double


Copy this code and paste it in your HTML
  1. NSLog(@"%@", [NSNumber numberWithInt:i]);
  2.  
  3. %@ Object
  4.  
  5. %d, %i signed int
  6. %u unsigned int
  7. %f float/double
  8. %1.2f to controll number of decimals
  9. %x, %X hexadecimal int
  10. %o octal int
  11. %zu size_t
  12. %p pointer
  13. %e float/double (in scientific notation)
  14. %g float/double (as %f or %e, depending on value)
  15. %s C string (bytes)
  16. %S C string (unichar)
  17. %.*s Pascal string (requires two arguments, pass pstr[0] as the first, pstr+1 as the second)
  18. %c character
  19. %C unichar
  20.  
  21. %lld long long
  22. %llu unsigned long long
  23. %Lf long double

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.