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
Post a Comment