I can get the value of a NSTokenField by doing [NSTokenField stringValue]
but this does not return the tokens individually. What I'm trying to get is the token fields in an array i.e ['token', 'token2']
.
I'm a bit ignorant when it comes to Cocoa/Objective-c so I wouldn't be surprised if I'm missing something obvious.
NSTokenField doesn't respond to count
so I'm not sure if it's even possible to get the tokens back.
Thanks.
From the Apple documentation:
To retrieve the objects represented by the tokens in a token field, send the token field an
objectValue
message. Although this method is declared byNSControl
,NSTokenField
implements it to return an array of represented objects. If the token field simply contains a series of strings,objectValue
returns an array of strings. To set the represented objects of a token field, use thesetObjectValue:
method, passing in an array of represented objects. If these objects aren’t strings,NSTokenField
then queries its delegate for the display strings to use for each token.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With