NSURLEffectiveIconKey with bookmark data
NSURLEffectiveIconKey with bookmark data
- Subject: NSURLEffectiveIconKey with bookmark data
- From: Noah Desch <email@hidden>
- Date: Fri, 9 Apr 2010 13:37:16 -0400
My application displays a potentially long list of items in an NSTableView. One of the columns represents files on the user's hard drive. This column is driven by the new bookmark data from the NSURL class. The bookmark data does not appear to be able to save effective icon data, however other data does work. Does anyone know of a way to get this to store the icon data?
Bookmark data for a given item is created as follows:
[[openPanel URL] bookmarkDataWithOptions:0 includingResourceValuesForKeys:
[NSArray arrayWithObjects:NSURLEffectiveIconKey,NSURLLocalizedNameKey,Nil]
relativeToURL:Nil error:Nil]
According to the docs this should create bookmark data that also includes the file's effective icon and localized name data so that I can access those two items without resolving the bookmarks. I would like to avoid resolving every bookmark in the table when they are displayed for performance reasons and because I don't want the user to be presented with bookmark resolution dialogs as they scroll through the list.
In my NSCell subclass I load the bookmark data as follows:
resources = [NSURL resourceValuesForKeys:[NSArray arrayWithObjects:NSURLEffectiveIconKey, NSURLLocalizedNameKey, Nil] fromBookmarkData:obj];
if ( resources ) {
[self setFileIcon:[resources objectForKey:NSURLEffectiveIconKey]];
[self setFileName:[resources objectForKey:NSURLLocalizedNameKey]];
return;
}
The result is that the name is displayed but the file icon is Nil. Stepping through the code shows that the resources dictionary only contains one entry (the localized name) instead of the expected two entries so the icon data is not being stored or retrieved. As far as I can see this behavior (inability to store icon data with the bookmark) is not documented anywhere.
-Noah
_______________________________________________
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