ios - Getting a string in textfield before a specific string in the textfield -


so textfield has following text. @"a big tomato red."

i want word before "is".

when type

  nsstring *somestring = [[textfield componentsseparatedbystring:@"is"]objectatindex:0]; 

i "a big tomato" instead of "tomato". in app people type things before "is" need string before "is". appreciate can get. *warning,

this difficult problem.

try this

nsstring *str = @"a big tomato red"; nsarray *arr = [str componentsseparatedbystring:@" "]; int index = [arr indexofobject:@"is"]; if(index > 1)     nsstring *str_tomato = arr[index-1]; else     //"is" first word of sentence 

as per yvesleborg's comment


Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -