I am trying to write a method to set the Desktop picture using
Scripting Bridge and System Events.
Header is generated via:
sdef /System/Library/CoreServices/System\ Events.app | sdp -fh --
basename SystemEvents
The working AppleScript is:
set picture of desktop 1 to POSIX file "/Some/file.jpg"
Here's the code I have:
SystemEventsApplication *systemEvents = [SBApplication
applicationWithBundleIdentifier:@"com.apple.systemevents"];
NSDictionary *props = [NSDictionary dictionaryWithObject:[NSURL
fileURLWithPath:@"/Some/file.jpg"] forKey:@"URL"];
SystemEventsDiskItem *picture = systemEvents
classForScriptingClass:@"disk item"] alloc] initWithProperties:props]
autorelease];
[[systemEvents diskItems] addObject:picture];
When I add it to the diskItems array, it pukes:
*** Terminating app due to uncaught exception 'NSGenericException',
reason: 'Apple event returned an error. Event =
'core'\'crel'{ 'kocl':'ditm', 'insh':'insl'{ 'kobj':'obj
'{ 'want':'file', 'from':'null'(), 'form':'indx',
'seld':'abso'($206C6C61$) }, 'kpos':'end ' }, 'prdt':{ 'url ':'furl'("file://localhost/Some/file.jpg
") } }
Error info = {
ErrorNumber = -1;
I've tried several variations, with using key @"path" and
@"POSIXPath". I've tried creating the object with just init instead of
initWithProperties. No luck.
Any tips?
Thanks,
Kevin
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com