惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - wingfay

【转载】解决 安装或卸载软件时报错Error 1001 的问题 Win7下做一个Kubernetes的NetCore项目Demo win7 升级Power Shell到4.0 .net Cache 需要注意的地方 SQL 字段修改 Powser Design 16.5 导入Mysql数据库的bug Druid中配置双数据库 ActiveMq Windows 配置优化 Eclipse使用Maven创建Web时错误:Could not resolve archetype 更新VS2017会出现“请更新 Visual Studio 安装程序 再继续” 提示 ipv6过审函数 转.iPhone开发网站、论坛、博客 Could not load type System.Security.Authentication..... [原创]Prism Command 和 IsEnabled 的冲突解决方法 [ZT]JScript下Array对象的性能问题 获取地区的Resolve Weather Location ID Using .NET C# LDAP Library(Novell.Directory.Ldap) WINDOWS下搭建LDAP服务器 [转帖]LDAP Schema的概念和基本要素
NSLog的使用
wingfay · 2011-03-31 · via 博客园 - wingfay

NSLog的定义

NSLog定义在NSObjCRuntime.h中,如下所示:

void NSLog(NSString *format, …);

基本上,NSLog很像printf,同样会在console中输出显示结果。不同的是,传递进去的格式化字符是NSString的对象,而不是chat *这种字符串指针。

示例

NSLog可以如下面的方法使用:

NSLog (@"this is a test");

NSLog (@"string is :%@", string);

NSLog (@"x=%d, y=%d", 10, 20);

但是下面的写法是不行的:

int i = 12345;

NSLog( @"%@", i );

原因是, %@需要显示对象,而int i明显不是一个对象,要想正确显示,要写成:

int i = 12345;

NSLog( @"%d", i );

格式

NSLog的格式如下所示:

  • %@     对象
  • %d, %i 整数
  • %u     无符整形
  • %f     浮点/双字
  • %x, %X 二进制整数
  • %o     八进制整数
  • %zu    size_t
  • %p     指针
  • %e     浮点/双字 (科学计算)
  • %g     浮点/双字 
  • %s     C 字符串
  • %.*s   Pascal字符串
  • %c     字符
  • %C     unichar
  • %lld   64位长整数(long long)
  • %llu   无符64位长整数
  • %Lf    64位双字