开发者

How can I set an int value in some code to be equal to a value in a text entry box?

I'm try开发者_高级运维ing to get a value from an object in my mac application.


NSControl, of which NSTextField is a subclass, has a method intValue, which gets you what you want. Set up an outlet in your controller and use Interface Builder to hook it up to the text field you care about. After that, your controller can just access it like:

int myInt = [myTextField intValue];

The outlet declaration would look something like:

IBOutlet NSTextField *myTextField;

Along with your controller's other instance variables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜