Re: Scripting Bridge running method passing an array
Re: Scripting Bridge running method passing an array
- Subject: Re: Scripting Bridge running method passing an array
- From: Kyle Sluder <email@hidden>
- Date: Fri, 30 Oct 2009 13:33:32 -0700
On Fri, Oct 30, 2009 at 12:55 PM, Scott <email@hidden> wrote:
> Through some help I was able to get this resolved. My problem was I
> didn't look at SBElementArray closely enough. I thought it was only
> used to get objects not pass them back to an application. Makes sense
> that Scripting Bridge needs to use it's own array's now that I think
> about it. I was trying to create a new array. Anyway for anyone in the
> future who is as bad at reading the developer docs as I am here is a
> working example of what I was trying to do it is actually pretty
> simple.
There are some quirks… the -exists method that the documentation
prescribes doesn't actually exist. So this doesn't work (using
OmniFocus names here because I don't have Airfoil):
OmniFocusDocument *document = [[[OmniFocus documents]
objectWithName:@"OmniFocus"] exists];
This results in a compiler error; defining this method instead results
in unrecognized selector exception.
Then I tried using -get:
OmniFocusDocument *document = [[[OmniFocus documents]
objectWithName:@"OmniFocus"] get];
BOOL exists = (document != nil);
But that didn't work because that's not how documents are identified.
So finally, this worked for Mail.app:
MailMailbox *mbox = [[[Mail mailboxes] objectWithName:@"ToDos"] get];
BOOL exists = (mbox != nil);
So there you have it.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden