NSString of selected text in NSTextView
NSString of selected text in NSTextView
- Subject: NSString of selected text in NSTextView
- From: Todd Heberlein <email@hidden>
- Date: Sat, 07 Nov 2009 17:57:05 -0800
This seems like a simple task, but it has become a series of steps. Am
I missing a simple method that will do this?
I have a Text View and want to get the selected text in an NSString
form. I can get an NSString for the entire NSTextView (-string), but
to get the string for just the selected text seems to take multiple
steps:
NSRange range = [theTextView selectedRange];
NSData* rtfData = [theTextView RTFFromRange: range];
NSAttributedString* aStr = [[NSAttributedString alloc]
initWithRTFData:rtfData documentAttributes: NULL];
NSString* str = [aStr string];
Is there a method that combines all these steps?
Thanks,
Todd
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden