How to parse NSString into BOOL in Objective-C?

Fire Fist picture Fire Fist · Jan 17, 2012 · Viewed 39.6k times · Source

I am programming in Objective-C for iOS. I would like to parse an object of type NSString into a scalar of type BOOL.

I have a value, and I know that it will either be @"YES" or @"NO", but that YES (or) NO value is NSString and I just want to change NSString into BOOL.

How can I do that?

Please answer me if you know.

Thanks for reading.

Answer

bschultz picture bschultz · Jan 17, 2012

I think it's this:

BOOL boolValue = [myString boolValue];