ApplescriptObjectiveC (ASOC): setLabel:forSegment:

Hi there,


I use ApplescriptObjectiveC (ASOC) in my programs, but I'm extremely bad at giving cocoa objects orders.

I saw that there was a command "call method ...", and it looked extremely handy, but it doesn't work on Lion (which my Mac uses).

1: Is there an alternative to "call method ..."?


Besides that:

2: Does anybody know tutorials or sites that offer free knowledge for ASOC?


And my real question:

I have a NSSegmentedControl (button), and I want to use the

(void)setLabel:(NSString *)label forSegment:(NSInteger)segment 
command.

As I've understood, I should change such commands into

logintextbutton's setLabel_("Delete") forSegment_(2)


But this throws up the error "Expected end of line, ect. but found identifier."

3: Who can solve this mystery?


Really, really thanks


Isaiah


P.S. I will only reward with "solved questions" for the third question.

Nevertheless I will reward "helpful answer" to every helpful answer (:

iMac, Mac OS X (10.7.5)

Posted on May 17, 2013 8:20 AM

Reply
1 reply

May 17, 2013 4:23 PM in response to IsaiahvanHunen

1. Call method was an AppleScript Studio command to call an arbitrary Cocoa method. This is not needed in ASObjC since it calls the various Cocoa methods directly.


2. The regular (free) Objective-C/Cocoa documentation is apparently what Apple expects you to use. There are a few ASObjC specific resources, for example MacScripter's AppleScriptObjC in Xcode tutorials, but the best documentation is still Shane Stanley's excellent AppleScriptObjC Explored ebook (not free).


3. One of the big differences with AppleScriptObjC (as you have found out) is the naming convention when using Cocoa methods. Instead of the names and arguments being mixed, the equivalent ASObjC method uses a more or less standard AppleScript handler name with underscores as placeholders for the arguments, so your example NSSegmentedControl statement would be:

logintextbutton's setLabel_forSegment_("Delete", 2)


See the AppleScriptObjC Release Notes for information about converting from Objective-C (there are also some conversion scripts out there that will convert methods from the documentation).

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

ApplescriptObjectiveC (ASOC): setLabel:forSegment:

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.