现在的位置: 首页 > 综合 > 正文

iPhone開發中的NSLog輸出格式

2014年09月20日 ⁄ 综合 ⁄ 共 450字 ⁄ 字号 评论关闭

我很多朋友到笑稱Objective C是火星文,
的確他是有許多語法跟規則跟之前所寫的程式語言有所差異,
光是做簡單除錯會用到的NSLog()輸出就跟大夥不一樣了,
所以我將輸出的格式化整理在這邊給大家參考:

%@ Object
%d, %i signed int
%u unsigned int
%f float/double
%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

抱歉!评论已关闭.