在Objective-C中设置文本字段的值

在Objective-C中设置文本字段的值,objective-c,cocoa,Objective C,Cocoa,我有一个名为resultsView的NSTextField,我想用字符串graphical\u availability填充它 我尝试了以下方法: [resultsView setValue:graphical_availability]; 但在运行时不断出现错误: 2012-08-13 08:39:08.468 App-Name[75231:6003] -[NSTextField setValue:]: unrecognized selector sent to instance 0x100

我有一个名为
resultsView
NSTextField
,我想用字符串
graphical\u availability
填充它

我尝试了以下方法:

[resultsView setValue:graphical_availability];
但在运行时不断出现错误:

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
因此,显然,
setValue
不被识别为我正在使用的
NSTextField
类上的方法。我是Objective-C的新手(显然),在苹果的文档中很难找到它

如何设置此文本字段的值


谢谢大家!

设置字符串值:
是您需要的方法

从:

概述

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


不要忘记使用下划线调用setter:

[_resultsView setStringValue:graphical_availability];