• 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: Maintaining an ordered array of attributes in an NSTextStorage subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Maintaining an ordered array of attributes in an NSTextStorage subclass


  • Subject: Re: Maintaining an ordered array of attributes in an NSTextStorage subclass
  • From: Graham Cox <email@hidden>
  • Date: Mon, 10 Aug 2009 23:43:01 +1000


On 10/08/2009, at 11:21 PM, Keith Blount wrote:

Thanks for the reply. I guess I lost the point in my long, rambling e-mail, so sorry about that. What I really meant to ask is *how* to maintain this list accurately. Given that the attribute can be added, removed, text can be copied and pasted, a range of text that has a comment associated with it might be cut in half and so on, what is the best approach for keeping this list updated as the text changes?


Ah, my bad - I guess the clue was in your message title ;-)

In theory, code is supposed to call beginEdiing/endEditing around any operation that edits the text so that might be one place you could override to handle this. Other methods in NSMutableAttributedString may need to be overridden to get information about affected ranges. There are only two primitive methods, according to the docs:

- (void)replaceCharactersInRange:(NSRange)aRange withString:(NSString *)aString

- (void)setAttributes:(NSDictionary *)attributes range:(NSRange)aRange

So those two should provide all the hooks you'd need. If your auxiliary array is kept sorted by range position it should be easy and efficient to locate the relevant entries affected by an edit in a given range. Ideally you'd want to manage the comments such that the text storage does all the hard work of maintaining the attribute runs/ ranges, and all you have to do is to add and delete comments in your array as necessary.

Still a bit vague, but might help with the inspiration...

--Graham


_______________________________________________

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: Maintaining an ordered array of attributes in an NSTextStorage subclass
      • From: Keith Blount <email@hidden>
References: 
 >Re: Maintaining an ordered array of attributes in an NSTextStorage subclass (From: Keith Blount <email@hidden>)

  • Prev by Date: Re: Adjusting UIAlertView position
  • Next by Date: Re: NSOperationQueue question
  • Previous by thread: Re: Maintaining an ordered array of attributes in an NSTextStorage subclass
  • Next by thread: Re: Maintaining an ordered array of attributes in an NSTextStorage subclass
  • Index(es):
    • Date
    • Thread