【问题标题】:Format specifies type 'unsigned int' but the argument has type 'id'格式指定类型“无符号整数”,但参数的类型为“id”
【发布时间】:2013-01-31 06:16:36
【问题描述】:
NSString *val = [NSString stringWithFormat:@"%u",[settingsMgr performSelector:NSSelectorFromString([[gets objectAtIndex:indexPath.section] objectAtIndex:indexPath.row])]];

在上面的代码中,我收到一条警告,其中settingsMgr 是对象类,getsNSMutableArray

【问题讨论】:

  • 你想在val中存储什么?
  • 显示你的代码和数组数据
  • 如文档所述,performSelector 方法返回 id 类型的值,但您使用字符串格式的 '%u' (unsigned int)。

标签: objective-c warnings


【解决方案1】:

NSMutableArray 不能保存标准类型(int、float、BOOL 等),因此它们被包装存储(主要在 NSNumber 中)。尝试将%u 更改为%@

【讨论】:

  • 没有其他问题,我尝试了另一个答案,它对我很有效。无论如何感谢您的回复。
猜你喜欢
  • 1970-01-01
  • 2014-04-23
  • 1970-01-01
  • 2012-08-06
  • 1970-01-01
  • 2016-09-29
  • 1970-01-01
  • 2020-08-02
  • 2015-06-10
相关资源
最近更新 更多