开发者

What is the equivalent of 'variable'.text in cocoa?

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 over value and setValue: 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 NSControl implement stringValue, intValue, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜