ios NSLog常见使用
NSLog常见输出格式
Table 1 Format specifiers supported by the NSString formatting methods and CFString formatting functions
|
Specifier |
Description |
|
%@ |
Objective-C object, printed as the string returned by descriptionWithLocale: if available, or description otherwise. Also works withCFTypeRef 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 |
下面可能也是比较常见的
NSLog(@"rect = %@",NSStringFromCGRect(self.view.frame));
NSLog(@"size = %@",NSStringFromCGSize(self.view.frame.size));
NSLog(@"point = %@",NSStringFromCGPoint(self.view.frame.origin));
NSLog 与 printf 的区别
1.NSLog会自己加上换行符
2.NSLog在Debug下会写到system.log中
3.NSLog会自动加上时间和进程信息.
4.NSLog支持%@去打印一个对象类型,当使用%@时,它会给对象发送消息description,所以如果你组合了一个新的类,你可以通过给自己重载description来实现打印DEBUG
ios NSLog常见使用的更多相关文章
- iOS的常见文件及程序的启动原理
一. iOS中常见文件 (一). Xcode6之前 创建项目,默认可以看见一个存放框架的文件夹 info文件以工程文件名开头,如:第一个项目-Info.plist 项目中默认有一个PCH文件 (二). ...
- iOS中常见 Crash 及解决方案
来源:枫影JustinYan 链接:http://justinyan.me/post/1609 一.访问了一个已经被释放的对象 在不使用 ARC 的时候,内存要自己管理,这时重复或过早释放都有可能导致 ...
- ios block常见的错误(一)
Block是OC中的一种数据类型,在iOS开发中被广泛使用. 在实际的使用和面试过程中,经常发现同事或面试者对block了解得不够透彻,本博文将列举常见block错误来对其加深理解. 示例代码1: ; ...
- iOS所有常见证书,appID,Provisioning Profiles配置说明及制作图文教程
转自holydancer的CSDN专栏,原文地址:http://blog.csdn.net/holydancer/article/details/9219333 概述: 苹果的证书繁锁复杂,制作管理相 ...
- iOS开发——高级篇——iOS中常见的设计模式(MVC/单例/委托/观察者)
关于设计模式这个问题,在网上也找过一些资料,下面是我自己总结的,分享给大家 如果你刚接触设计模式,我们有好消息告诉你!首先,多亏了Cocoa的构建方式,你已经使用了许多的设计模式以及被鼓励的最佳实践. ...
- iOS测试常见崩溃
什么是崩溃日志,从哪里能得它? iOS设备上的应用闪退时,操作系统会生成一个崩溃报告,也叫崩溃日志,保存在设备上.崩溃日志上有很多有用的信息,包括应用是什么情况下闪退的.通常,上面有每个正在执行线程的 ...
- iOS开发常见BUG和一些小技巧(ps:耐心看完,很实用)
[385][scrollView不接受点击事件,是因为事件传递失败] // // MyScrollView.m // Created by beyond on 15/6/6. // Copyright ...
- iOS中常见的设计模式——单例模式\委托模式\观察者模式\MVC模式
一.单例模式 1. 什么是单例模式? 在iOS应用的生命周期中,某个类只有一个实例. 2. 单例模式解决了什么问题? 想象一下,如果我们要读取文件配置信息,那么每次要读取,我们就要创建一个文件实例,然 ...
- ios文本常见属性
文本属性Attributes 1.NSKernAttributeName: @10 调整字距 kerning 字距调整 2.NSFontAttributeName : [UIFont systemFo ...
随机推荐
- Codeigniter 在Active Record中限制批量更新数目
今天手头电商项目有个需求是:将订单中的优惠券自动发放给买家,所以要只更新优惠券表中的某几行数据,查了手册和网络都没有解决办法. 一开始用循环和遍历来做都是错的,因为update语句一下就更新掉所有符合 ...
- uglifyjs2压缩混淆js文件
uglifyjs可以用来压缩混淆js文件,发布release版本应用利器.在StackOverflow浏览了一下,相比Google Closure和YUI compressor,uglifyjs被推荐 ...
- Android studio 加速编译方法
JRebel for Android 是一个Android Studio的插件,可以大大加速Android Studio的编译速度,对于小项目来说或许不明显:但是当项目达到一定的规模时,它对于Andr ...
- IT小喇叭,关注于移动互联网创新、创业的科技媒体
IT小喇叭(itxiaolaba.cn),成立于2015年6月,成都芮嘉科技有限公司旗下品牌.主要负责媒体资源整合,媒体渠道接入,产品宣传,资源整合.对接等,是企业产品宣传,品牌营销的首选. 通过近一 ...
- [fortify] 不安全的函数eregi()
PHP 5.4/5.3弃用函数eregi() memory_limit绕过漏洞 [日期:2012-04-02] 来源:Linux社区 作者:Linux [字体:大 中 小] 发布日期:2012- ...
- [转]如何拷贝一个 SQL Server 的表
这篇短文将介绍几种拷贝 SQL Server 表的方法.第一种方式是最简单的在同一个数据库里将表拷贝到另外一个表.你需要记住的是,拷贝表的时候并不会拷贝表的约束和索引.下面是代码模板和简单的使用方法: ...
- checked属性
使用checked属性,你可以设置复选按钮和单选按钮默认被选中. 为此,只需在input元素中添加属性checked <input type="radio" name=&qu ...
- 各廠商ERP系統架構圖連結 (ERP流程圖)(轉)
各廠商ERP系統架構圖連結 (ERP流程圖) 資料來源 Google圖片搜尋ERP整理而來 資通電腦 ArgoERP 資通電腦 Oracle ERP 鼎新電腦 Workflow ERP鼎新電腦 S ...
- hdu 5720
考虑三个树枝:a,b,c若c是将要抛出的树枝,那么形成三角形的条件是a+b>c and a-b<c 可以写成 c属于开区间(a-b,a+b)对于每个C和许许多多的其他边,如何保证C不构成三 ...
- ASP.NET 上传文件最大值调整
首先,最容易找到的是web.config下面配置: <!--maxRequestLength=50MB--> <httpRuntime targetFramework="4 ...