• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSString of selected text in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSString of selected text in NSTextView
      • From: Mark Gallegly <email@hidden>
    • Re: NSString of selected text in NSTextView
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Porting non-Mac OS X app to Cocoa
  • Next by Date: Re: NSString of selected text in NSTextView
  • Previous by thread: Re: Embedded Frameworks in Plugin & Action Bundles
  • Next by thread: Re: NSString of selected text in NSTextView
  • Index(es):
    • Date
    • Thread