定义 说明
%@ Objective-C object, printed as the string returned by descriptionWithLocale: if available, or description otherwise. Also works with CFTypeRef objects, returning the result of the CFCopyDescription function.
%% ‘%’ character
%d, %D, %i Signed 32-bit integer (int)
%u, %U Unsigned 32-bit integer (unsigned int)
%hi Signed 16-bit integer (short)
%hu Unsigned 16-bit integer (unsigned short)
%qi Signed 64-bit integer (long long)
%qu Unsigned 64-bit integer (unsigned long long)
%x Unsigned 32-bit integer (unsigned int), printed in hexadecimal using the digits 0–9 and lowercase a–f
%X Unsigned 32-bit integer (unsigned int), printed in hexadecimal using the digits 0–9 and uppercase A–F
%qx Unsigned 64-bit integer (unsigned long long), printed in hexadecimal using the digits 0–9 and lowercase a–f
%qX Unsigned 64-bit integer (unsigned long long), printed in hexadecimal using the digits 0–9 and uppercase A–F
%o, %O Unsigned 32-bit integer (unsigned int), printed in octal
%f 64-bit floating-point number (double)
%e 64-bit floating-point number (double), printed in scientific notation using a lowercase e to introduce the exponent
%E 64-bit floating-point number (double), printed in scientific notation using an uppercase E to introduce the exponent
%g 64-bit floating-point number (double), printed in the style of %e if the exponent is less than –4 or greater than or equal to the precision, in the style of %f otherwise
%G 64-bit floating-point number (double), printed in the style of %E if the exponent is less than –4 or greater than or equal to the precision, in the style of %f otherwise
%c 8-bit unsigned character (unsigned char), printed by NSLog() as an ASCII character, or, if not an ASCII character, in the octal format \\ddd or the Unicode hexadecimal format \\udddd, where d is a digit
%C 16-bit Unicode character (unichar), printed by NSLog() as an ASCII character, or, if not an ASCII character, in the octal format \\ddd or the Unicode hexadecimal format \\udddd, where d is a digit
%s Null-terminated array of 8-bit unsigned characters. %s interprets its input in the system encoding rather than, for example, UTF-8.
%S Null-terminated array of 16-bit Unicode characters
%p Void pointer (void *), printed in hexadecimal with the digits 0–9 and lowercase a–f, with a leading 0x
%L Length modifier specifying that a following a, A, e, E, f, F, g, or G conversion specifier applies to a long double argument
%a 64-bit floating-point number (double), printed in scientific notation with a leading 0x and one hexadecimal digit before the decimal point using a lowercase p to introduce the exponent
%A 64-bit floating-point number (double), printed in scientific notation with a leading 0X and one hexadecimal digit before the decimal point using a uppercase P to introduce the exponent
%F 64-bit floating-point number (double), printed in decimal notation
%z Length modifier specifying that a following d, i, o, u, x, or X conversion specifier applies to a size_t or the corresponding signed integer type argument
%t Length modifier specifying that a following d, i, o, u, x, or X conversion specifier applies to a ptrdiff_t or the corresponding unsigned integer type argument
%j Length modifier specifying that a following d, i, o, u, x, or X conversion specifier applies to a intmax_t or uintmax_t argument
Table 2 Format specifiers for data types
类型 定义 建议
NSInteger %ld or %lx Cast the value to long
NSUInteger %lu or %lx Cast the value to unsigned long
CGFloat %f or %g %f works for floats and doubles when formatting; but see below warning when scanning
CFIndex %ld or %lx The same as NSInteger
pointer %p %p adds 0x to the beginning of the output. If you don’t want that, use %lx and cast to long.
long long %lld or %llx long long is 64-bit on both 32- and 64-bit platforms
unsigned long long %llu or %llx unsigned long long is 64-bit on both 32- and 64-bit platforms

OC中格式化输出符号的更多相关文章

  1. iOS 格式化输出符号与类型转换

    1.iOS 格式化输出符号 %@    对象 %d,   %i 整数 %u     无符号整形 %f      浮点(双字节) %x,   %X  二进制整数 %o     八进制整数 %zi     ...

  2. C语言中格式化输出的转换说明的fldwidth和precision解析

    首先说什么是C语言的格式化输出,就是printf和它的几个变种(grep -E "v?(sn|s|f)printf").像这些函数都有一个参数format,format中可以加点转 ...

  3. printf 格式化输出符号详细说明(转)

    %a             浮点数.十六进制数字和p-记数法(C99)%A 浮点数.十六进制数字和p-记法(C99)%c 一个字符(char) %C           一个ISO宽字符 %d 有符 ...

  4. 李洪强iOS开发之OC[002] - OC中注释以及@符号的使用

  5. MYSQL 、Oracle、SQLServer 数据库中时间的格式化输出

    在MYSQL 中格式化输出 date_forma t(date,'yyyyMMddHHmmss') Oracle 中格式化输出 to_char(time ,'yyyyMMddHHmmss') SQL ...

  6. python中实现格式化输出 %用法

    当我们在python中需要打印出特定格式的内容时可以用到这个方法,方法介绍如下: 例如我们现在要收集用户的一些个人信息,这时候我们的代码如下: name=input("name: " ...

  7. Python中格式化format()方法详解

    Python中格式化format()方法详解 Python中格式化输出字符串使用format()函数, 字符串即类, 可以使用方法; Python是完全面向对象的语言, 任何东西都是对象; 字符串的参 ...

  8. C语言 printf格式化输出,参数详解

      有关输出对齐 int main(int argc, char* argv[]){ char insertTime[20] = {"1234567890"}; double in ...

  9. python格式化输出及大量案例

    python格式化输出符号及大量案例 1.格式化输出符号 python格式化输出符号 格式化符号 含义 %c 转化成字符 %r 优先使用repr()函数进行字符串转化 %s 转换成字符串,优先使用st ...

随机推荐

  1. textLayout_1.0.0.595.swz

    使用ai制作的矢量素材,导出到flash里面.生成swf时.有的时候会多一个textLayout_1.0.0.595.swz的文件. 这会导致导出的swf无法加载使用.会显示不出来. 解决办法是: 检 ...

  2. Nginx【第一篇】安装

    一.简介 Nginx("engine x")是一款是由俄罗斯的程序设计师 Igor Sysoev 所开发高性能的 Web 和 反向代理 服务器,也是一个 IMAP/POP3/SMT ...

  3. Android读取Manifest文件下Application等节点下的metadata自定义数据

    介绍 Android在 提供了meta-date使用键值对的形式实现自定义配置.一般使用中作为渠道标识.可以用 在<application>,<activity>,<ac ...

  4. android开发之wheel控件使用详解

    出门在外生不起病呀,随便两盒药60多块钱.好吧,不废话了,今天我们来看看wheel控件的使用,这是GitHub上的一个开源控件,用起来十分方便,我们可以用它做许多事情,比如做一个自定义的datepic ...

  5. Android_EditText

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&q ...

  6. 纯js写“运动”框架

    所谓“运动”不一定真的是运动,在连续的一段时间内改变某一样式都可以成为“运动”. 先写几个会用到的函数 //获取某一元素的指定样式 function getstyle (element, target ...

  7. 页面嵌套 Iframe 产生缓存导致页面数据不刷新问题

    最近遇到个比较古怪的问题:当页面嵌套多个 Iframe 时会出现 Iframe 里包含的页面无法看到最新的页面信息. 初步解决方案,在 Iframe 指向的页面地址后缀添加一个随机数或者时间戳.这样能 ...

  8. Multiple methods named 'status' found with mismatched result, parameter type or attributes

    出现这个这个错误, 有可能是由于你直接通过一个数组的索引获取一个对象(或模型)然后直接调用这个对象(或模型)的某个方法 例如: NSString *status = [self.models[inde ...

  9. java新手笔记12 单例

    1.单例 package com.yfs.javase; public class Singleton { //private static final Singleton single = new ...

  10. jeesite 经常出现java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderL解决思路

    本来jeesite是用的maven,但是我开发的项目用这个框架没用maven, 经常报这个错,我能用的办法就是将springmvc—web.jar包删掉,然后重新添加