App Sandbox: NSWorkspace and NSURL return generic icons for special folders

Originator:matt
Number:rdar://10101475 Date Originated:09-Sep-2011
Status:Duplicate/9720925 Resolved:
Product:Mac OS X Product Version:10.7.1
Classification:UI/Usability Reproducible:Always
 
Summary:

When a sandboxed app requests an icon for a special folder like ~/Downloads a generic folder icon is returned instead of the standard icon shown in Finder.

Steps to Reproduce:

Execute the following code in a sandboxed Cocoa app with the com.apple.security.files.downloads.read-write entitlement:

NSString *downloadsPath = [@"~/Downloads" stringByExpandingTildeInPath];
NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:downloadsPath];
[[icon TIFFRepresentation] writeToFile:[downloadsPath stringByAppendingPathComponent:@"folder.tiff"] atomically:NO];

NSURL *url = [NSURL fileURLWithPath:downloadsPath];
NSDictionary *values = [url resourceValuesForKeys:[NSArray arrayWithObject:NSURLEffectiveIconKey] error:NULL];
icon = [values objectForKey:NSURLEffectiveIconKey];
[[icon TIFFRepresentation] writeToFile:[downloadsPath stringByAppendingPathComponent:@"folder2.tiff"] atomically:NO];

Expected Results:

Both image files contain the standard Downloads folder icon shown in Finder.

Actual Results:

The folder image is a generic folder icon and the folder2 image is a symlink folder icon.

Regression:

The example code works as expected in non-sandboxed applications.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!