¡@

Home 

2014/10/15 ¤U¤È 10:15:32

iphone Programming Glossary: updatedtext

Replacing Text in a UITextView

http://stackoverflow.com/questions/1628422/replacing-text-in-a-uitextview

NSString text create final version of textView after the current text has been inserted NSMutableString updatedText NSMutableString alloc initWithString textView.text updatedText insertString text atIndex range.location NSRange replaceRange.. the current text has been inserted NSMutableString updatedText NSMutableString alloc initWithString textView.text updatedText insertString text atIndex range.location NSRange replaceRange range endRange range if text.length 1 handle paste replaceRange.length.. 1 look back one characters length of hi minus one replace hi with hello for the inserted range int replaceCount updatedText replaceOccurrencesOfString @ hi withString @ hello options NSCaseInsensitiveSearch range replaceRange if replaceCount 0..