• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AppleScript Integration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript Integration


  • Subject: Re: AppleScript Integration
  • From: p3consulting <email@hidden>
  • Date: Sun, 23 Nov 2003 10:26:00 +0100

> What I would like to do from within my Objective-C Cocoa application is
> call an AppleScript that reads all the ToDo information from iCal and
> then get that information in to an Objective-C Dictionary. The first
> part of that is to actually figure out how to run an AppleScript from
> Objective-C. I have this code:
>
> NSAppleScript * exportToDo;
> exportToDo = [[NSAppleScript alloc] initWithSource:
> @"exportToDo.scpt"];
> [exportToDo executeAndReturnError:nil];
>

initWithSource is to be to passed the source code of the script
in your case use
- (id)initWithContentsOfURL:(NSURL *)url error:(NSDictionary
**)errorInfo

The url parameter being created with the NSUrl instance method:
- (id)initFileURLWithPath:(NSString *)path

(the complete path)

Then if you want to get the result you should not ignore it as you do
by passing nil to executeAndReturnError !

NSDictionary *resultDict ;
[exportToDo executeAndReturnError:&resultDict];

> This doesn't work though. Do I need to have the path to the
> AppleScript? How do I get the path? I added a new AppleScript build
> phase and in the bundle the relative path to the script is
> Contents/Resources/Scripts/exportToDo.scpt. What I was reading on the
> web says this:
>
> To call an applescript in your bundle, get the bundle location and
> append @"/Contents/Scripts/applescriptnamehere.scpt". This will give
> you your compiled applescript.
>
> How do I get the bundle location?
>

[NSBundle mainBundle]


Pascal Pochet
P3 Consulting
email@hidden
http://www.p3-consulting.net
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: [guilt] Taking too much CPU cycles
  • Next by Date: Re: Reading from an NSInputStream
  • Previous by thread: AppleScript Integration
  • Next by thread: KeyDown events in a ComboBox the 2nd
  • Index(es):
    • Date
    • Thread