I am trying to use Apple Pages (from iWork) with Objective-C's Scripting Bridge.
This is the working AppleScript:
tell application "Pages"
set name of item 1 of contents of (get selection) to "myLittleTextBox"
end tell
How can I achieve the same thing in Objective-C with Scripting Bridge?
I tried the tip under Cocoa Scripting Bridge and <contents> element but no luck ...
The strange thing is that reading the properties is no problem:
PagesApplication *myPages = [SBApplication applicationWithBundleIdentifier:@"com.apple.iWork.Pages"];
NSLog(@"myPages.selection.properties:%@",myPages.selection.properties);
... but I've had no luck setting or accessing the objects in the selection.
Of course, I could send the AppleScript via NSAppleScript
but hey, that would be too easy. ;)
Well I can get the property item. The returned property object is an Array.
id selObject = pages.selection.properties;
NSString* theName = [[selObject objectAtIndex:0]objectForKey:@"name"];
NSLog(@"theName = %@",theName);
And to set it:
id selObject2 = pages.selection.get;
[selObject2 setValue:@"myPage" forKey:@"name"];