I am trying to create an iOS app which involves one main if statement to check if a text box contains certain text. I would like to check for multiple instances of a certain word but I don’t want to do multiple if statements as this will dramatically slow down the performance of the app.
How can I check if a word matches that of a word in an NSArray, and if it does, return a NSString associated with that word in another text box?
You can create an
NSDictionaryof the words you are checking against mapped against theNSStringyou want returned when that word is entered:EDIT: To iterate over the list so you can test if the keywords are contained in the textbox, you can do the following (assume
wordsandwordFromTextBoxare set-up as before):