2012-08-13 82 views
3

我有一個NSTextField,調用resultsView,我想用字符串graphical_availability填充。設置Objective-C中的textField的值

我已經試過如下:

[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的新手(很明顯),並且很難在蘋果的文檔中找到它。

如何設置此文本字段的值?

謝謝!

回答

7

setStringValue:是您需要的方法。

NSTextField class reference

概述

父類,的NSControl,提供了用於設置文本字段的值,例如該方法:setStringValue :, setDoubleValue:等。有相應的方法來檢索值。

0

不要忘記下劃線調用setter方法:

[_resultsView setStringValue:graphical_availability];