• 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: Performance: Drawing hundreds of short text strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: access multiple NSTextFields as an array?
  • Next by Date: Waiting for UIWebView with Dispatch Semaphores
  • Previous by thread: Re: Performance: Drawing hundreds of short text strings
  • Next by thread: No TCP connection established after ARP request
  • Index(es):
    • Date
    • Thread