• 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
Re: NSString of selected text in NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString of selected text in NSTextView


  • Subject: Re: NSString of selected text in NSTextView
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 9 Nov 2009 09:50:07 -0800


On Nov 9, 2009, at 9:37 AM, Kyle Sluder wrote:

On Mon, Nov 9, 2009 at 9:28 AM, Douglas Davidson <email@hidden> wrote:
Yes, that's correct. Within a given text view, the character indexes are
the same between the text storage and its underlying string, and these are
the character indexes used by the layout manager and the text view.

The documentation seems to be in conflict on this point. -[NSAttributedString string] says the following:

This method doesn’t strip out attachment characters; use NSText's string method to extract just the linguistically significant characters.

That doesn't sound right.

For performance reasons, this method returns the current backing store of the attributed string object. If you want to maintain a snapshot of this as you manipulate the returned string, you should make a copy of the appropriate substring.

But -[NSText string] also says this:

For performance reasons, this method returns the current backing store of the text object. If you want to maintain a snapshot of this as you manipulate the text storage, you should make a copy of the appropriate substring.

This is correct.

Which implies that -[NSText string] is implemented to just return
[[self textStorage] string], which would defy -[NSAttributedString
string]'s documentation.  I think NSAttributedString is in error here;
will file a doc bug soon.

Please do.

Douglas Davidson_______________________________________________

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: Kyle Sluder <email@hidden>
References: 
 >NSString of selected text in NSTextView (From: Todd Heberlein <email@hidden>)
 >Re: NSString of selected text in NSTextView (From: Kyle Sluder <email@hidden>)
 >Re: NSString of selected text in NSTextView (From: Todd Heberlein <email@hidden>)
 >Re: NSString of selected text in NSTextView (From: Jens Alfke <email@hidden>)
 >Re: NSString of selected text in NSTextView (From: Douglas Davidson <email@hidden>)
 >Re: NSString of selected text in NSTextView (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: NSString of selected text in NSTextView
  • Next by Date: Cocoa Sounds
  • Previous by thread: Re: NSString of selected text in NSTextView
  • Next by thread: Re: NSString of selected text in NSTextView
  • Index(es):
    • Date
    • Thread