In an iPhone application I can write something like this with no error (And have ‘someThing’ a label.:
NSString *thing = someThing.text;
But I am trying to do this in cocoa. I need to set the text on the label ‘someThing’ as ‘thing’. It doesn’t work in Cocoa, but does in iOS. Any ideas?
Thanks
Cocoa classes don’t use as many properties (
.foo), rather, they use getters ([object foo]) and setters ([object setFoo:value]). In reality properties are just a wrapper overvalueandsetValue:methods.To set the text of a
NSTextField(label), you would use[myLabel setStringValue:@"Hello World!"].To get its value you would use
NSString *string = [myLabel stringValue].Most subclasses of
NSControlimplementstringValue,intValue, etc.