Re: Performance: Drawing hundreds of short text strings
Re: Performance: Drawing hundreds of short text strings
- Subject: Re: Performance: Drawing hundreds of short text strings
- From: Leonardo <email@hidden>
- Date: Tue, 21 Dec 2010 16:25:39 +0100
- Thread-topic: Performance: Drawing hundreds of short text strings
You could create an array of objects grouping the parameters of your strings
For example:
typedef struct
{
NSAttributedString *text; // it already contains color and font
NSPoint position;
} MyObj;
Or you can even create your own class MyObj
The you create the array containing a bunch of these objects MyObj
NSMutableArray *mStrings = [[NSMutableArray array] retain];
for(i = 0; i < totStrings; i++){
create the object MyObj
set string, color and positions
add to the array
[mStrings addObject:anObj];
}
Then on the drawRect: method of your NSView you iterate through the array
mStrings and draw the strings with their parameters.
- (void)drawRect:(NSRect)rect
{
[super drawRect:rect];
for(anObj in mStrings ){
[anObj.text drawAtPoint:anObj.position];
}
}
Regards
-- Leonardo
_______________________________________________
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