Re: iconForFile
Re: iconForFile
- Subject: Re: iconForFile
- From: Ron Fleckner <email@hidden>
- Date: Sat, 17 Nov 2007 09:24:31 +1100
Hi Lorenzo,
it works on any file. I tried it on the special Home folders as well
to make sure. A couple of other people have posted that
NSWorkspace's -iconForFile works pretty fast for them, too. I think
that there must be some other issue involved in your case that you
need to identify. Are you doing something else at the same time which
might be hogging the CPU? I'm no expert, but I would start looking
at basic things first. Something like, "Have you plugged in the
power cord? Is the unit on?" and those kind of questions.
Ron
On 17/11/2007, at 12:32 AM, Lorenzo wrote:
Did you try to display the icons of the folders in the Home folder?
I mean, Music, Pictures, Documents, Public, Sites...
Anyway iconForFile works slowly even with normal folders.
I could display a pre-loaded folder icon, but in this case I cannot
longer
show the icons of the above special folders.
Best Regards
--
Lorenzo
email: email@hidden
From: Ron Fleckner <email@hidden>
Date: Fri, 16 Nov 2007 12:23:44 +1100
On 16/11/2007, at 11:29 AM, Lorenzo wrote:
Hi,
I use [NSWorkspace sharedWorkspace] iconForFile:filePath] to get
the 128x128
icon of a file or a folder. It works well, but it is amazingly
slow. It get
the icon in about 1 second, much more that getting a thumbnail of a
large
jpg file by CGImageSourceCreateThumbnailAtIndex.
Is a faster way, even an old carbon way, working on Tiger and
Leopard?
Best Regards
--
Lorenzo
email: email@hidden
Well, on my machine (G4 DP 1.25Ghz 1 Gig RAM)), it takes 0.002
seconds to do it. There is something else happening in your case I
reckon.
Here's my complete IBAction:
- (IBAction)chooseFile:(id)sender
{
NSOpenPanel *panel;
NSString *chosenFile;
int result;
NSString *title = @"Choose the file";
NSString *okButtonTitle = @"Choose";
panel = [NSOpenPanel openPanel];
[panel setCanChooseDirectories:YES];
[panel setCanChooseFiles:YES];
[panel setAllowsMultipleSelection:NO];
[panel setTitle:title];
[panel setPrompt:okButtonTitle];
result = [panel runModalForDirectory:nil file:nil types:nil];
NSLog(@"time 1");
if (result == NSOKButton) {
chosenFile = [panel filename];
NSImage *aImage = [[NSWorkspace sharedWorkspace]
iconForFile:chosenFile];
[myView setFileIcon:aImage];
[myView setSize:NSMakeSize(128.0,128.0)];
[myView setNeedsDisplay:YES];
[slider setFloatValue:128.0];
[currentSize setStringValue:@"128"];
}
NSLog(@"time 2");
}
2007-11-16 12:19:00.538 GetFileIcons[4121] time 1
2007-11-16 12:19:00.540 GetFileIcons[4121] time 2
Ron
_______________________________________________
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