如何在NSLog中打印布尔标志? [英] How to print Boolean flag in NSLog?

查看:92
本文介绍了如何在NSLog中打印布尔标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在NSLog中打印布尔值标志的值?

Is there a way to print value of Boolean flag in NSLog?

推荐答案

>

Here's how I do it:

BOOL flag = YES;
NSLog(flag ? @"Yes" : @"No");

?:是三元条件运算符形式:

?: is the ternary conditional operator of the form:

condition ? result_if_true : result_if_false

相应替换实际的日志字符串。

Substitute actual log strings accordingly where appropriate.

这篇关于如何在NSLog中打印布尔标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆