• 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: Attributes in a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Attributes in a string


  • Subject: Re: Attributes in a string
  • From: Greg Titus <email@hidden>
  • Date: Wed, 28 May 2003 09:58:54 -0700

On Wednesday, May 28, 2003, at 08:24 AM, Marco Binder wrote:

Hello,

I want to "attach" some objects to delimited character ranges of a
string. An NSLinkAttribute in an NSAttributedString at the first glance
look perfect for this. But: in my case, ranges can overlap, i.e. one
char can refer to multiple objects! I guess, I could use cutom
attribute types with a unique identifier for each of my objects. The of
course, it will become harder to extract my custom attributes from the
list of all attributes at a given char index. I d have to check the
keys of all attributes against a list of my object identifiers.

Does anyone have a better idea as how to deal with this?

How about a single custom attribute, whose value is an array of one or more of your multiple objects?

The code for setting an object on a range will be more complex (because you'll have to get the existing arrays in the desired range, make new arrays if the old ones overlap a range outside the desired range, and add the new object to each array). However, extracting the objects at a position will be simple, since you only need to ask for a single attribute, and you'll get back an array of objects at that index.

Whether you go with this approach, or the one you outline above (unique attributes for each possible object) depends upon how often you'll be setting vs. looking up the attributes.

Hope this helps,
- Greg
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Attributes in a string
      • From: Marco Binder <email@hidden>
References: 
 >Attributes in a string (From: Marco Binder <email@hidden>)

  • Prev by Date: Re: Where in a prefPane can I do some polling, and then update the UI?
  • Next by Date: Recording the time a thread took to execute
  • Previous by thread: Attributes in a string
  • Next by thread: Re: Attributes in a string
  • Index(es):
    • Date
    • Thread