将Scanf与ObjC和iPhone结合使用

将Scanf与ObjC和iPhone结合使用

问题描述:

尝试制作iPhone应用程序,并阅读我之前推荐的教程和书籍:)我试图查找有关scanf/将用户输入数据从文本字段存储到变量中的信息,以便以后使用在我的程序中.文本字段实际上是一个数字字段,因此我尝试保存输入的整数而不是文本,因为在我的情况下将不会有任何整数.我在这里走错了路吗?任何帮助将不胜感激.

trying to make an iPhone app and going through the tutorials and books recommended by those before me :) I'm trying to find information on the scanf/storing user input data from a text field into a variable which I can use later in my program. The text field is actually a number field, so I am trying to save the integers they input and not the text since there won't be any in my case. Am I on the wrong path here? Any help would be greatly appreciated.

如果我本质上在尝试将数字输入保存到始于

what about if i am essentially trying to save the input that is a number to begin with

您要 NSNumberFormatter .数据格式化程序(

You want NSNumberFormatter. The data formatters ( Apple Guide) handle conversions to and from strings as well as formatting for output.