• 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
Call Objective-C methods from any script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Call Objective-C methods from any script


  • Subject: Call Objective-C methods from any script
  • From: daniel <email@hidden>
  • Date: Mon, 17 Jan 2005 12:33:35 -0800


It occurred to me that it would be cool for any script to be able to take advantage of the "call method" functionality included with AppleScript Studio applications. An interesting way of getting this is simply to make a "stand-in" AppleScript Studio application to do your bidding. For example, if you produce an empty AS Studio app named "MyTestApp", then you can use it to access the wealth of Cocoa and Foundation classes:


WebSafeString("http://www.apple.com/Fun with spaces.html")

on WebSafeString(myString)
tell application "MyTestApp"
set myURLString to call method "stringWithString:" of class "NSString" with parameter myString
set myFixedURLString to call method "stringByAddingPercentEscapesUsingEncoding:" of myURLString with parameter 30
end tell
end WebSafeString


--> "http://www.apple.com/Fun with spaces.html";

Maybe others have already figured this out but I thought it was a pretty nifty hack. Maybe it wouldn't be too hard to put together a Scripting Addition that bridged all the AppleScriptKit terminologies to regular scripts?

Daniel

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Call Objective-C methods from any script
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: one odd character
  • Next by Date: Re: Call Objective-C methods from any script
  • Previous by thread: Re: one odd character
  • Next by thread: Re: Call Objective-C methods from any script
  • Index(es):
    • Date
    • Thread