替换NSTextView的某个字符串

替换NSTextView的某个字符串


            NSString *textContents = [[self.textView textStorage] string];
            NSRange replaceRange = NSMakeRange(0, [self.textView.textStorage length]);
            NSRange find = {0,0};
            find = [textContents rangeOfString:@"REPLACE_STR" options:0 range:replaceRange];
            if (find.length > 0) {
                [self.textView replaceCharactersInRange:find withString:newString];
            }




猜你喜欢

转载自blog.csdn.net/lcxhjg/article/details/81059419
今日推荐