NSWorkspace desktopImageURLForScreen doesn't return image path

Originator:supergradha
Number:rdar://16811496 Date Originated:05-May-2014 02:42 PM
Status:Open Resolved:
Product:OS X Product Version:10.8
Classification:UI Reproducible:Always
 
Summary:
The documentation for [NSWorkspace desktopImageURLForScreen:] says that it returns the NSURL for the desktop image for the given screen. This is incorrect, when the user sets a folder of pictures the returned URL points to the containing directory. See http://stackoverflow.com/questions/14099363/get-the-current-wallpaper-in-cocoa.

Steps to Reproduce:
1. Write an objc program with the following content:

#import <AppKit/AppKit.h>

#import <stdlib.h>

int main(void)
{
	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
	NSWorkspace *w = [NSWorkspace sharedWorkspace];
	NSURL *url = [w desktopImageURLForScreen:[NSScreen mainScreen]];
	NSString *path = [url path];
	printf("%s\n", [path UTF8String]);
	[pool release];
	return 0;
}

2. Compile like "cc current_desktop_path.m -framework AppKit".
3. Execute the a.out binary and see how it returns the path to the directory, not to the current image being displayed.

Expected Results:
The returned path should point to the currently visible image.

Actual Results:
Returns the path to a temporary folder containing aliases to the folder of images.

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!