前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >NSLog中使用的格式符

NSLog中使用的格式符

作者头像
EltonZheng
发布2021-01-26 14:13:56
3220
发布2021-01-26 14:13:56
举报
文章被收录于专栏:Elton的技术分享博客

NSLog在输出的时候,可以使用很多C中的格式符号,与print一样。 具体含义如下

Specifier

Description

\u000a%@\u000a

Objective-C object, printed as the string returned by \u000adescriptionWithLocale:\u000a if available, or \u000adescription\u000a otherwise. Also works with \u000aCFTypeRef\u000a objects, returning the result of the \u000aCFCopyDescription\u000a function.

\u000a%%\u000a

\u000a'%'\u000a character

\u000a%d\u000a, \u000a%D\u000a, \u000a%i\u000a

Signed 32-bit integer (\u000aint\u000a)

\u000a%u\u000a, \u000a%U\u000a

Unsigned 32-bit integer (\u000aunsigned int\u000a)

\u000a%hi\u000a

Signed 16-bit integer (\u000ashort\u000a)

\u000a%hu\u000a

Unsigned 16-bit integer (\u000aunsigned short\u000a)

\u000a%qi\u000a

Signed 64-bit integer (\u000along long\u000a)

\u000a%qu\u000a

Unsigned 64-bit integer (\u000aunsigned long long\u000a)

\u000a%x\u000a

Unsigned 32-bit integer (\u000aunsigned int\u000a), printed in hexadecimal using the digits 0–9 and lowercase a–f

\u000a%X\u000a

Unsigned 32-bit integer (\u000aunsigned int\u000a), printed in hexadecimal using the digits 0–9 and uppercase A–F

\u000a%qx\u000a

Unsigned 64-bit integer (\u000aunsigned long long\u000a), printed in hexadecimal using the digits 0–9 and lowercase a–f

\u000a%qX\u000a

Unsigned 64-bit integer (\u000aunsigned long long\u000a), printed in hexadecimal using the digits 0–9 and uppercase A–F

\u000a%o\u000a, \u000a%O\u000a

Unsigned 32-bit integer (\u000aunsigned int\u000a), printed in octal

\u000a%f\u000a

64-bit floating-point number (\u000adouble\u000a)

\u000a%e\u000a

64-bit floating-point number (\u000adouble\u000a), printed in scientific notation using a lowercase e to introduce the exponent

\u000a%E\u000a

64-bit floating-point number (\u000adouble\u000a), printed in scientific notation using an uppercase E to introduce the exponent

\u000a%g\u000a

64-bit floating-point number (\u000adouble\u000a), printed in the style of \u000a%e\u000a if the exponent is less than –4 or greater than or equal to the precision, in the style of \u000a%f\u000a otherwise

\u000a%G\u000a

64-bit floating-point number (\u000adouble\u000a), printed in the style of \u000a%E\u000a if the exponent is less than –4 or greater than or equal to the precision, in the style of \u000a%f\u000a otherwise

\u000a%c\u000a

8-bit unsigned character (\u000aunsigned char\u000a), printed by \u000aNSLog()\u000a as an ASCII character, or, if not an ASCII character, in the octal format \u000a\ddd\u000a or the Unicode hexadecimal format \u000a\udddd\u000a, where \u000ad\u000a is a digit

\u000a%C\u000a

16-bit Unicode character (\u000aunichar\u000a), printed by \u000aNSLog()\u000a as an ASCII character, or, if not an ASCII character, in the octal format \u000a\ddd\u000a or the Unicode hexadecimal format \u000a\udddd\u000a, where \u000ad\u000a is a digit

\u000a%s\u000a

Null-terminated array of 8-bit unsigned characters. \u000a%s\u000a interprets its input in the system encoding rather than, for example, UTF-8.

\u000a%S\u000a

Null-terminated array of 16-bit Unicode characters

\u000a%p\u000a

Void pointer (\u000avoid \*\u000a), printed in hexadecimal with the digits 0–9 and lowercase a–f, with a leading \u000a0x\u000a

\u000a%L\u000a

Length modifier specifying that a following \u000aa\u000a, \u000aA\u000a, \u000ae\u000a, \u000aE\u000a, \u000af\u000a, \u000aF\u000a, \u000ag\u000a, or \u000aG\u000a conversion specifier applies to a \u000along double\u000a argument

\u000a%a\u000a

64-bit floating-point number (\u000adouble\u000a), printed in scientific notation with a leading \u000a0x\u000a and one hexadecimal digit before the decimal point using a lowercase \u000ap\u000a to introduce the exponent

\u000a%A\u000a

64-bit floating-point number (\u000adouble\u000a), printed in scientific notation with a leading \u000a0X\u000a and one hexadecimal digit before the decimal point using a uppercase \u000aP\u000a to introduce the exponent

\u000a%F\u000a

64-bit floating-point number (\u000adouble\u000a), printed in decimal notation

\u000a%z\u000a

Length modifier specifying that a following \u000ad\u000a, \u000ai\u000a, \u000ao\u000a, \u000au\u000a, \u000ax\u000a, or \u000aX\u000a conversion specifier applies to a \u000asize\_t\u000a or the corresponding signed integer type argument

\u000a%t\u000a

Length modifier specifying that a following \u000ad\u000a, \u000ai\u000a, \u000ao\u000a, \u000au\u000a, \u000ax\u000a, or \u000aX\u000a conversion specifier applies to a \u000aptrdiff\_t\u000a or the corresponding unsigned integer type argument

\u000a%j\u000a

Length modifier specifying that a following \u000ad\u000a, \u000ai\u000a, \u000ao\u000a, \u000au\u000a, \u000ax\u000a, or \u000aX\u000a conversion specifier applies to a \u000aintmax\_t\u000a or \u000auintmax\_t\u000a argument


本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档