如何打印布尔[重复](How to print BOOLs [duplicate])

编程入门 行业动态 更新时间:2024-10-19 13:22:06
如何打印布尔[重复](How to print BOOLs [duplicate])

这个问题在这里已经有了答案:

如何在NSLog中打印布尔标志? 11个答案

我想在没有任何编译器警告的情况下打印BOOL(记录为有符号字符):

NSLog(@"Parsing Result = %hhd", parsingResult); // inside some iOS program. Xocde 6

但我得到“格式指定类型'char',但参数的类型为'BOOL'(aka'bool')”。

This question already has an answer here:

How to print Boolean flag in NSLog? 11 answers

I want to print a BOOL (which is documented to be a signed char) without any compiler warnings:

NSLog(@"Parsing Result = %hhd", parsingResult); // inside some iOS program. Xocde 6

But I get "Format specifies type 'char' but the argument has type 'BOOL' (aka 'bool')".

最满意答案

NSLog(parsingResult ? @"YES" : @"NO"); NSLog(parsingResult ? @"YES" : @"NO");

更多推荐

本文发布于:2023-08-06 04:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1444477.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:布尔   print   duplicate   BOOLs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!