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:

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

       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)

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


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

Thanks Craig. This helps immensely.