I am writing a Cocoa application and I would like to create a Numbers table from my application using the Scripting Bridge. I created the Numbers.h file and linked ScriptingBridge.framework in the directions in the Apple Documentation . Below is the code that I use to try to just create a Numbers document and save it.
NSString *path = @"/Users/username/Desktop/Test.numbers";
NumbersApplication *numbers = [SBApplication applicationWithBundleIdentifier:@"com.apple.iWork.Numbers"];
[numbers activate];
NumbersDocument *document = [[[numbers classForScriptingClass:@"document"] alloc] initWithProperties:[NSDictionary dictionaryWithObjectsAndKeys:project.title, @"name", nil]];
[[numbers documents] addObject:document];
[document saveAs:nil in:[NSURL URLWithString:path]];
The code compiles and runs, and when I try to use the saveAs: in: method, I get the following error:
- [SBProxyByClass saveAs: in:]: the object has not yet been added to the container; selector not recognized [self = 0x2005912e0]
Is there anything else I need to do besides adding the document to the [numbers documents] array?
AppleScript, Scripting Bridge, .