NSTextView will generally make sure that the selection is a reasonable range. One complication is that in general NSTextView supports multiple discontiguous selected ranges. If such a selection is in use then just calling -selectedRange will not capture all of it. If there are attachments in the text, they will appear as replacement characters in the string. I don't think that's really a reason to do such a convoluted thing as getting out RTF and converting it back to text. Better generally to deal with the text content as a string (- string) or attributed string (-textStorage).

Douglas Davidson

On Nov 7, 2009, at 6:06 PM, Kyle Sluder <kyle.slu...@gmail.com> wrote:

On Sat, Nov 7, 2009 at 5:57 PM, Todd Heberlein <todd_heberl...@mac.com> wrote:
This seems like a simple task, but it has become a series of steps. Am I
missing a simple method that will do this?

[[myTextView string] substringWithRange:[myTextView selectedRange];

(Warning, composed in Mail.  Potential thorny issues with text
attachment characters, surrogate pairs, composed characters, marked
text… "the selected text" isn't as simple of a concept as it may
seem.)

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/ddavidso%40apple.com

This email sent to ddavi...@apple.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to