• 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: NSTextFieldCell Subclass for Image+Text, any faster way?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextFieldCell Subclass for Image+Text, any faster way?


  • Subject: Re: NSTextFieldCell Subclass for Image+Text, any faster way?
  • From: Scott Stevenson <email@hidden>
  • Date: Mon, 20 Nov 2006 21:23:24 -0800


On Nov 20, 2006, at 8:59 PM, Brian Amerige wrote:

I tried playing with releasing and allocating the image, caching it (wasn't really familiar with that), or retaining the data, but nothing seemed to help.

Thank you for posting sample code from your project! :)

What you need to do is to figure out all the icon stuff outside of the delegate method. You only need to fetch the icons from NSWorkspace once -- when the set of files change.

Right now it looks like you're probably doing it every time the table redraws (or at least every time it reloads). Make some sort of simple class like BARemoteFile, which stores the file path and associated icon.

Your data source code should end up looking like this:

if ( [aCell isImageAndTextCell] )
{
	NSImage *icon = [[remoteFiles objectAtIndex:rowIndex] icon];
	[aCell setImage:icon];
}

Also notice how you don't have to keep comparing the class name to a string. Just have the class itself answer what sort of thing it is by making a method:

	- (void) isImageAndTextCell { return YES; }

I don't know if this will make the app "fast enough" (the main issue could be elsewhere), but it will certainly minimize the amount of time spent in this one method.

Hope that helps.

   - Scott
_______________________________________________
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


References: 
 >NSTextFieldCell Subclass for Image+Text, any faster way? (From: Brian Amerige <email@hidden>)
 >Re: NSTextFieldCell Subclass for Image+Text, any faster way? (From: Scott Stevenson <email@hidden>)
 >Re: NSTextFieldCell Subclass for Image+Text, any faster way? (From: Brian Amerige <email@hidden>)

  • Prev by Date: Re: NSTextFieldCell Subclass for Image+Text, any faster way?
  • Next by Date: Re: New WebView
  • Previous by thread: Re: NSTextFieldCell Subclass for Image+Text, any faster way?
  • Next by thread: Re: NSTextFieldCell Subclass for Image+Text, any faster way?
  • Index(es):
    • Date
    • Thread