ios - Swift Error, it replace the last item only -


i have code needs find , delete string in textview. string saved in array. problem deletes string last item in array. instead, need delete items in textview. code :

for value in values! {     print("array value= \(value)")      newstring = reasonview.text.stringbyreplacingoccurrencesofstring("\(value)", withstring: "", options: nsstringcompareoptions.literalsearch, range: nil) } 

how can resolve that? thank in advance!

you replacing in reasonview.text , result discarded...

try this:

newstring = reasonview.text value in values! {     print("array value= \(value)")      newstring = newstring.stringbyreplacingoccurrencesofstring("\(value)", withstring: "", options: nsstringcompareoptions.literalsearch, range: nil) } 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -