简体   繁体   中英

Call Swift/objective-c method from Applescript

I am trying to call a swift or Objective-C API from applescript with has argument. Currently my Objective-C method looks as below -

- (void)updateInfoLabel:(NSString*)information;

I am trying to call it from AppleScript as -

on infoUpdate()
    current application's MyClass's alloc()'s init()'s updateInfoLabel("Hello World")
end infoUpdate

Any help, pointers would be appreciated.

Finally, I was able to figure this out. Below is how we can call an Objective-C method from apple script -

on infoUpdate()
    current application's MyClass's alloc()'s init()'s updateInfoLabel:"Hello World"
end infoUpdate

The important part is, we do not have to pass the argument from the bracket, instead, it has to be sent after : (colon)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM