Saturday, March 28, 2020

#1 2020-02-23 09:38:40 am

Marius_Magnificus
Member
Registered: 2019-05-05
Posts: 16

NSButton GET title issue

Hi everyone,

I have the following NSButton and I can set its title programmatically like this:

Applescript:

myButton's setTitle:"Processing"

The problem arise when I try to get its value (The title's string);

myButton's getTitle

Can’t get getTitle of «class ocid» id «data optr00000000F084620001000000». (error -1728)


I've tried this code as well but it yields just a different error message:

myButton's getTitle()

[NSButton getTitle]: unrecognized selector sent to instance 0x103c4b6b0 (error -10000)

Obviously there is a key concept that I'm missing here but I'm not able to find the solution...

Best,

Marius

Offline

 

#2 2020-02-23 09:50:08 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11673
Website

Re: NSButton GET title issue

The key concept is that the getter is the method without set – actually the setter is the method with set prefix and lowerCamelCased.

And if you want to use the result in AppleScript you have to coerce it to an AppleScript type

Applescript:

myButton's title() as text

It's always worth it to have a look at the documentation

Last edited by StefanK (2020-02-23 09:55:22 am)


regards

Stefan

Offline

 

#3 2020-02-23 10:23:32 am

Marius_Magnificus
Member
Registered: 2019-05-05
Posts: 16

Re: NSButton GET title issue

Exactly what I was looking for.

Thank you for point me out in the right direction and your quick response.

Marius.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)