Re: NSString of selected text in NSTextView
Re: NSString of selected text in NSTextView
- Subject: Re: NSString of selected text in NSTextView
- From: Kyle Sluder <email@hidden>
- Date: Mon, 9 Nov 2009 09:37:07 -0800
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.
>
> 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.
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.
--Kyle Sluder
_______________________________________________
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