Is there a format specifier that works with Boolean values?

后端 未结 6 1713
悲&欢浪女
悲&欢浪女 2021-02-12 14:17

I want to do something like this:

NSLog(@\"You got: %x\", booleanValue);

where x is the specifier. But I can\'t find one! I want to avoid:

6条回答
  •  借酒劲吻你
    2021-02-12 14:28

    Here are two things that work:

    NSLog(@"You got: %@",booleanValue ? @"YES" : @"NO");
    

    or you can cast:

    NSLog(@"You got: %d", (int)booleanValue);
    

    Which will output 0 or 1

提交回复
热议问题