ObjectiveC从String中解析整数 [英] ObjectiveC Parse Integer from String
本文介绍了ObjectiveC从String中解析整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从数组中提取字符串(包含整数),然后在函数中将其用作int。我正在尝试使用intValue将其转换为int。
I'm trying to extract a string (which contains an integer) from an array and then use it as an int in a function. I'm trying to convert it to a int using intValue.
这是我一直在尝试的代码。
Here's the code I've been trying.
NSArray *_returnedArguments = [serverOutput componentsSeparatedByString:@":"];
[_appDelegate loggedIn:usernameField.text:passwordField.text:(int)[[_returnedArguments objectAtIndex:2] intValue]];
我收到此错误:
传递'loggedIn :::'的参数3使得整数
的指针没有强制转换
passing argument 3 of 'loggedIn:::' makes pointer from integer without a cast
怎么了?
推荐答案
我真的不知道这个问题有多难,但我设法这样做了:
I really don't know what was so hard about this question, but I managed to do it this way:
[myStringContainingInt intValue];
It应该注意的是,您也可以这样做:
It should be noted that you can also do:
myStringContainingInt.intValue;
这篇关于ObjectiveC从String中解析整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文