How to parse NSString into BOOL in Objective-C?

I think it's this:

BOOL boolValue = [myString boolValue];

You should probably use NSString's -boolValue. To quote the documentation directly:

[Returns t]he Boolean value of the receiver’s text. Returns YES on encountering one of "Y", "y", "T", "t", or a digit 1-9—the method ignores any trailing characters. Returns NO if the receiver doesn’t begin with a valid decimal text representation of a number.

That would seem to match your input cases.


if ([string isEqualToString: @"YES"])
  foo();
else
  bar();