在Objective-C中设置textField的值

Con*_*nor 3 cocoa objective-c

我有一个NSTextField叫做resultsView我想填充字符串graphical_availability.

我尝试过以下方法:

[resultsView setValue:graphical_availability];
Run Code Online (Sandbox Code Playgroud)

但在运行时不断收到错误:

2012-08-13 08:39:08.468 App-Name[75231:6003] -[NSTextField setValue:]: unrecognized selector sent to instance 0x100509730
2012-08-13 08:39:08.470 App-Name[75231:6003] An uncaught exception was raised
2012-08-13 08:39:08.470 App-Name[75231:6003] -[NSTextField setValue:]: unrecognized selector sent to instance 0x100509730
Run Code Online (Sandbox Code Playgroud)

因此,显然setValue不被认为是NSTextField我正在使用的类的方法.我是Objective-C的新手(显然)并且在Apple的文档上找不到它.

如何设置此textField的值?

谢谢!

jrt*_*ton 7

setStringValue: 是你需要的方法.

NSTextField类引用:

概观

父类NSControl提供了设置文本字段值的方法,例如:setStringValue:,setDoubleValue:等.有相应的方法来检索值.