• 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: iconForFile is slow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iconForFile is slow


  • Subject: Re: iconForFile is slow
  • From: David Remahl <email@hidden>
  • Date: Thu, 18 Apr 2002 13:03:02 +0200

> icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
>
> iconForFile is very slow. Anyone written a faster replacement? One
> problem is that I usually only need the 16x16 imagerep, but this call
> returns a 16x16, 32x32 and 128x128.
>
> Thanks,
>
> -steve

Steve,

Troy Stephen's IconFamily class has a method:

- initWithIconOfFile:(NSString*)path

that gets an IconFamilyHandle for any file using Carbon calls. It also has
code for getting NSBitmapImageRep's from such a handle. The easiest thing is
to do:

IconFamily *iFam = [IconFamily iconFamilyWithIconOfFile:@"yourfile"];
NSImage *icon = [iFam imageWithAllReps];. That will do just what the
NSWorkspace method does and return all icon sizes.

I don't think there is any way to load just part of an icon from a resource
file, but there are ways that you can get any size once you got your
IconFamilyHandle.

Perhaps using IconRef's would be faster as well, I don't know.

/ David
_______________________________________________
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.

References: 
 >iconForFile is slow (From: Steve Gehrman <email@hidden>)

  • Prev by Date: Re: NSNumberFormatter problem?
  • Next by Date: Re: CELL PROBLEM! HELP!!! YES!!!
  • Previous by thread: Re: iconForFile is slow
  • Next by thread: Class hierarchy weirdness.
  • Index(es):
    • Date
    • Thread