カーソルが現在ある場所にテキストを挿入したいので、以下のコードがあります
NSString *contentsToAdd = [myData objectAtIndex:row];
NSMutableString *tfContent = [[NSMutableString alloc] initWithString:[self.myTextView text]];
// add content where the cursor was
[tfContent insertString:contentsToAdd atIndex:myCursorPosition.location];
[self.myTextView setText:tfContent];
[tfContent release];
これは以下のように機能します
Hi
HiFriend
テキストを追加する前後に 1 つのスペースを残したいです (こんにちは友人)。
では、どうすればいいのでしょうか?