Friday, December 15, 2017

#1 2009-09-09 05:31:36 pm

Whiterock
Member
Registered: 2009-09-09
Posts: 30

Foundation Classes and ApplescriptOBjC

Having gone through the posts in this section (and all over the internet) I haven't figured out how to deal with simple objc calls:

Applescript:

on returnsTokens(theString, theDelimiter)
   return call method "componentsSeparatedByString:" of theString with parameter theDelimiter
end returnsTokens -- of class NSString

Do  I have to make an entire script for this with NSString as parent. I've tried. Strings in Applescript don't seem to be NSStrings anymore in Snow Leopard. The call method doesn't work. Nor does

Applescript:

return theString's componentsSeparatedByString_(theDelimiter)

or any variation I've tried in 2 days. This Snow leopard is extremely frustrating. I did go through Craig's tutorials and they are very helpful.

Model: iMac7,1
AppleScript: XCode 3.2
Browser: Safari 531.9
Operating System: Mac OS X (10.6)

Offline

 

#2 2009-09-09 05:37:18 pm

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: Foundation Classes and ApplescriptOBjC

Since we are dealing with methods from the NSString class we address it in our request.
I believe if we convert items to their respective Objective-C types then we will have
fewer issues when executing methods on those types.

What I mean by this is that if we are calling NSString methods on a string we should
first convert that string into an NSString.

-hth

Applescript:


on returnsTokens(theString, theDelimiter)
   tell class "NSString" of current application
       set theString to its stringWithString_(theString)
       return theString's componentsSeparatedByString_(theDelimiter)
   end tell
end returnsTokens


Filed under: NSString

Offline

 

#3 2009-09-09 07:31:15 pm

Whiterock
Member
Registered: 2009-09-09
Posts: 30

Re: Foundation Classes and ApplescriptOBjC

Thanks Craig. This helps immensely.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)