Is there a format specifier that works with Boolean values?

后端 未结 6 1715
悲&欢浪女
悲&欢浪女 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:42

    You can cast it to an int and use %d:

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

    Or use something like this:

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

提交回复
热议问题