NSTextField到uint16_t [英] NSTextField to uint16_t

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

问题描述

我的iPhone应用程序中有一个文本字段,我想转换用户输入的内容并将其转换为 uint16_t 。我怎么能这样做?

I have a text field in my iPhone app and I want to convert what the user enters and convert that to a uint16_t. How can I do that?

该文本框仅用于输入数字。

The text box will only be their for entering numbers.

推荐答案

这应该有效:

uint16_t integer = (uint16_t)[myTextField.text integerValue];

这将采用文本字段的文本,将其转换为整数并将其转换为 uint16_t 。请注意,如果用户输入值大于65,535 (或者小于0),它将无效。

This will take the text field's text, convert it to an integer and cast it to a uint16_t. Note that it will not work if the user enters a value bigger than 65,535 (or less than 0 for that matter).

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

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