Creating iPhoto albums using Cocoa Scripting Bridge

Posted by robinjam on Stack Overflow See other posts from Stack Overflow or by robinjam
Published on 2010-05-10T12:35:42Z Indexed on 2010/05/10 13:34 UTC
Read the original article Hit count: 278

I'm tearing my hair out trying to create a new album from a Cocoa Application. In applescript it's a nice simple procedure:

tell application "iPhoto"
    new album name "Album"
end tell

But I can't work out how this is done in Cocoa via the Scripting Bridge. I've tried this:

iPhotoApplication *iPhoto = [SBApplication applicationWithBundleIdentifier:@"com.apple.iPhoto"];
iPhotoAlbum *newAlbum = [[[[iPhoto classForScriptingClass:@"album"] alloc] initWithProperties:[NSDictionary dictionaryWithObject:@"Album" forKey:@"name"]] autorelease];
[[iPhoto albums] addObject:newAlbum];

But that had no effect.

Please help!

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa