我正在努力从 Cocoa 应用程序创建新专辑。在 applescript 中,这是一个很好的简单过程:
tell application "iPhoto"
new album name "Album"
end tell
但我无法通过 Scripting Bridge 在 Cocoa 中解决这个问题。我试过这个:
iPhotoApplication *iPhoto = [SBApplication applicationWithBundleIdentifier:@"com.apple.iPhoto"];
iPhotoAlbum *newAlbum = [[[[iPhoto classForScriptingClass:@"album"] alloc] initWithProperties:[NSDictionary dictionaryWithObject:@"Album" forKey:@"name"]] autorelease];
[[iPhoto albums] addObject:newAlbum];
但这没有任何效果。
请帮忙!