Recognizing multiple string values in a single action

cocoa, objective-c

Solution

Create a set of answers you're looking for and test if the string in question is in there.

NSSet *successStrings = [NSSet setWithObjects:@"Whatever1",
                                              @"Whatever2",
                                              @"Whatever3",
                                              nil];
if ([successStrings containsObject:st]) {
    [outputDisplay setStringValue:@"Success"];
}

(An array would also work, but a set is specialized for testing membership, so it's a better fit for what we're doing here.)

Problem

Thanks again for the help. I have a simple action that checks the stringValue of a textField, and if it matches - a status message prints in a second textField: ``` if (textField.stringValue == (@"Whatever" )){ [outputDisplay setStringValue:@"Success"]; ``` My question is how do I implement multiple input stringValue options in this method? For example "Whatever" "Whatever1, Whatever2" all return "Success" in the outputDisplay. thanks. Paul

Original source