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

推荐订阅源

S
SegmentFault 最新的问题
Spread Privacy
Spread Privacy
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
SecWiki News
SecWiki News
腾讯CDC
P
Privacy International News Feed
Webroot Blog
Webroot Blog
J
Java Code Geeks
爱范儿
爱范儿
A
About on SuperTechFans
S
Secure Thoughts
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
D
DataBreaches.Net
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Security Latest
Security Latest
Forbes - Security
Forbes - Security
小众软件
小众软件
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
量子位
MongoDB | Blog
MongoDB | Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
The Exploit Database - CXSecurity.com
Help Net Security
Help Net Security
V
Visual Studio Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 聂微东
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs

博客园 - 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位双字