Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有一种方法可以在 Objective-C 中将 BOOL 转换为 NSString?
例如:
BOOL a = YES; NSLog(@"a is %i",a);
但输出是“a is 1”,我希望它打印 YES。
您可以使用条件运算符从布尔值返回字符串。
BOOL a = YES; NSLog(@"a is %@", a ? @"YES" : @"NO");