iphone - Objective C 从字符串中解析整数

我正在尝试从数组中提取一个字符串(其中包含一个整数),然后将其用作函数中的 int。我正在尝试使用 intValue 将其转换为 int。

这是我一直在尝试的代码。

  NSArray *_returnedArguments = [serverOutput componentsSeparatedByString:@":"];
  [_appDelegate loggedIn:usernameField.text:passwordField.text:(int)[[_returnedArguments objectAtIndex:2] intValue]];

我收到此错误:

passing argument 3 of 'loggedIn:::' makes pointer from integer without a cast

怎么了?

最佳答案

我真的不知道这个问题有什么难的,但我设法做到了:

[myStringContainingInt intValue];

需要注意的是,你也可以这样做:

myStringContainingInt.intValue;

https://stackoverflow.com/questions/3559088/

相关文章:

objective-c - 如何在 Objective-C 中转换对象

ios - UIActionSheet 取消按钮的奇怪行为

objective-c - 深拷贝一个 NSArray

iphone - 如何使 UIView 的 subview 居中

objective-c - 允许与另一个 UIView 下的 UIView 交互

objective-c - 检查当前线程是否是主线程

objective-c - "Auto Layout still required after ex

objective-c - NSLog 覆盖描述方法中对象的内存地址

iphone - cocoa 应用程序的 info plist 中的 "bundle display

objective-c - 如何在 Objective-C 中执行回调