从NSTextField获取值 [英] Get value from NSTextField

查看:124
本文介绍了从NSTextField获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 NSTextField ,我需要得到字段的值到一个变量。 c> NSString 您将使用:

  NSString * myString = [theTextField stringValue]; 

对于 int ,您将使用: / p>

  int myInt = [theTextField intValue]; 

有许多其他方法可以从控件获取值。请参阅 NSControl 参考资料/ApplicationKit/Classes/NSControl_Class/index.html#//apple_ref/doc/uid/20000073-SW8rel =nofollow noreferrer>获取和设置控制的值部分



以下是一个列表:




  • doubleValue

  • floatValue

  • intValue / li>
  • integerValue

  • objectValue / li>
  • stringValue

  • attributStringValue / li>

I have an NSTextField and I need to get the field's value into a variable. What's the appropriate method?

解决方案

For an NSString you would use:

NSString *myString = [theTextField stringValue];

For an int you would use:

int myInt = [theTextField intValue];

There are many other methods for getting the value from a control. Have a look at the NSControl reference for more info, under the "Getting and Setting the Control’s Value" section.

Here's a list:

  • doubleValue
  • floatValue
  • intValue
  • integerValue
  • objectValue
  • stringValue
  • attributedStringValue

这篇关于从NSTextField获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆