1

Objective-C の Scripting Bridge で Apple Pages (iWork から) を使用しようとしています。

これは動作中の AppleScript です。

tell application "Pages"
    set name of item 1 of contents of (get selection) to "myLittleTextBox"
end tell

Scripting Bridge を使用して Objective-C で同じことを達成するにはどうすればよいですか?

Cocoa Scripting Bridge と <contents> 要素の下でヒントを試しました が、うまくいきませんでした ...

奇妙なことに、プロパティの読み取りは問題ありません。

PagesApplication *myPages = [SBApplication applicationWithBundleIdentifier:@"com.apple.iWork.Pages"];
NSLog(@"myPages.selection.properties:%@",myPages.selection.properties);

...しかし、選択範囲内のオブジェクトを設定したり、アクセスしたりすることはできませんでした。

もちろん、AppleScript を介して送信することもできますNSAppleScriptが、それは簡単すぎます。;)

4

2 に答える 2

1

さて、プロパティアイテムを取得できます。返されるプロパティ オブジェクトは配列です。

id  selObject = pages.selection.properties;


NSString*  theName = [[selObject objectAtIndex:0]objectForKey:@"name"];
NSLog(@"theName = %@",theName);

そしてそれを設定するには:

 id selObject2 =  pages.selection.get;


[selObject2 setValue:@"myPage"  forKey:@"name"];
于 2013-05-20T17:31:20.707 に答える