I have a textview and i need to be able to remove the selected text [ i mean i want to delete the text which are highlighted] for that i did as below
Code
(void)textViewDidChangeSelection:(UITextView *)textView {
NSRange range = textView.selectedRange;
myTextView.text = [myTextView.text stringByReplacingCharactersInRange:range withString:@""];
}
but it is crashing , how to implement this functionality here
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFString replaceCharactersInRange:withString:]: Range or index out of bounds'
Pls let me know
It's working fine on xcode version 3.2.5. Check the delegates of the UITextView are connected to the file Owner in the Interface Builder.
-(void) textViewDidChangeSelection:(UITextView *)textView {
NSRange range = textView.selectedRange;
myTextView.text = [myTextView.text stringByReplacingCharactersInRange:range withString:@""];
}