objective-c - 文本字段中的 Xcode NSString

标签 objective-c xcode macos nsstring

我对 Xcode 和 Objective-C 完全陌生,但我已经成功创建了一个 btton,当用户单击此按钮时,文本字段中会显示一个数字,但我似乎找不到放置文本的方法在那里。

-(IBAction) button1pressed: (id) sender {
[field1 setIntValue:36];
}

最佳答案

-(IBAction) button1pressed: (id) sender {
    [field1 setStringValue:@"some text"];
}

继承自NSControl的方法,文档位于:http://developer.apple.com/library/mac/documentation/cocoa/reference/ApplicationKit/Classes/NSControl_Class/Reference/Reference.html#//apple_ref/occ/instm/NSControl/setStringValue :

关于objective-c - 文本字段中的 Xcode NSString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5033435/

相关文章:

ios - 返回 UITableViewCell 自定义单元格

ios - GrandCentralDispatch 大下载队列最终耗尽内存

ios - 如何在 IOS 中重新加载 UIBarButtonItem

c++ - 本地 CGEventRef 是否被视为指针?

objective-c - 没有要编译的架构(ONLY_ACTIVE_ARCH=YES,active arch=x86_64,VALID_ARCHS=i386)

ios - UICollectionView 消失

ios - 邮件撰写 View Controller 文本颜色不会改变

macOS 辅助功能检查器不适用于 Slack

cocoa - 是否有等效的 -applicationDidReceiveMemoryWarning : on the Mac

objective-c - 如何在swift中使用其他类的指针