Re: Attributes in a string
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.