First of all, you must add the %@ formatting specifier. It should look like this:
NSLog(@"Is Kind of NSString: %@", ([thing isKindOfClass:[NSString class]]) ? @"YES" : @"NO");
You can also extract the conversion from BOOL to NSString using the extern function, like Apple, using NSStringFromCGRect , NSStringFromClass , etc.
Create a utils file or add the following code to an existing header:
And also add the following code to the implementation:
//NSString+TypeConversion.m NSString *NSStringFromBOOL(BOOL aBool) { return aBool ? @"YES" : @"NO"; }
So, now you can use this function in other places, and your code will become more clear and multiple:
#import "NSString+TypesConversion.h" NSLog(@"Is Kind of NSString: %@", NSStringFromBOOL([thing isKindOfClass:[NSString class]]));
HammerSlavik Jun 16 '16 at 7:54 on 2016-06-16 07:54
source share