Re: Attributes in a string
Re: Attributes in a string
- Subject: Re: Attributes in a string
- From: Marco Binder <email@hidden>
- Date: Wed, 28 May 2003 22:34:47 +0200
Thanks Greg,
I ve also thought about that approach in the meantime. However, also
the looking-up part will require more work. If I dont only want to
retrieve all objects associated with one char but also the effective
range of chars pointing to one of these objects, it will again require
a bit more work than simply calling attribute:atIndex:effectiveRange: .
i ll have to sleep it over before I make the decision.
Thanks again,
Marco
Am Mittwoch, 28.05.03, um 18:58 Uhr (Europe/Berlin) schrieb Greg Titus:
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.
--
|\ /| email@hidden
http://www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
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.