I have a bool value associated with a call I want to pass out of my iOS program as a string. I have tried the following:
NSString *connectedString = [self.selectedBeacon.isConnected stringValue];
But I'm not getting anything out.
Can someone please correct me?
If isConnected is a BOOL type it shouldn't even compile. If it's NSNumber you should get "1" or "0".
Do you want "YES" to "NO" string? Solution:
A) If a BOOL type:
NSString *connectedString = self.selectedBeacon.isConnected ? @"YES" : @"NO";
B) If NSNumber add a category method to this class like:
- (NSString *)boolValueString {
// if this contains BOOL value
return [self boolValue] ? @"YES" : @"NO";
}
Converting Bool To String Swift 3 / Swift 4
let boolValue = true
print (String(boolValue))
Log
true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With