NSAttributedString behaving badly
NSAttributedString behaving badly
- Subject: NSAttributedString behaving badly
- From: "D.K. Johnston" <email@hidden>
- Date: Mon, 03 Jul 2006 07:15:41 -0700
I have an array of NSString text lines, each of which is terminated
by \n. I want to append each line (textLine), along with some line
citation information, to an NSAttributedString (theText), which will
then be displayed in a read-only text view. The citation information
is in an NSDictionary called "attributes". I'm doing it like this:
// construct a range for the new line
unsigned location = [theText length];
NSRange range = NSMakeRange(location, 1);
// add the new line to the text string
id attrib = [[NSAttributedString alloc] initWithString:textLine];
[theText appendAttributedString:attrib];
[attrib release];
// apply the attributes
[theText setAttributes:attributes range:range];
The idea is that I can get the citation data for the selected line in
the text view simply by reading the attributes of its first character.
But something is going wrong. When I process an NSString array
containing about 8,000 lines, applying 2 attributes, it takes about 3
seconds to complete the loop. That's bad enough. But when I process
an NSString array containing about 12,000 lines, applying 3
attributes, the loop is still running after 3 minutes.
There must be a recursive rat in there somewhere. But I can't figure
out where. I haven't been able to find anything in the
NSAttributedString documentation or programming guide that has
enlightened me on this.
dkj
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden