【问题标题】:'NSInvalidArgumentException', reason: '-[__NSArrayM identifier]: unrecognized selector sent to instance 0x9f996a0''NSInvalidArgumentException',原因:'-[__NSArrayM 标识符]:无法识别的选择器发送到实例 0x9f996a0'
【发布时间】:2013-09-14 05:45:21
【问题描述】:

以上错误发生在这一行:

  _nextRegionsArray=[[NSMutableArray alloc] init];
  [_nextRegionsArray addObject:_geofences_ending_regions[_positionOfRoute]];

_nextRegionsArray 在这里声明:

@implementation PSLocationManager
{
    NSMutableArray *_nextRegionsArray;
}

geofences_ending_regions 是一个包含 CLRegions 的数组。

为什么会出现这个错误:

'NSInvalidArgumentException', reason: '-[__NSArrayM identifier]: unrecognized selector sent to instance 0x9f996a0' 

【问题讨论】:

  • 您的错误消息表明您正在向可变数组发送identifier 消息。这不是发送到数组的有效消息。您的代码示例中没有任何内容表明这一点。您的问题可能出在其他地方。如果您包含更多代码,它将非常有帮助。除此之外,请搜索您的代码以查看您将identifier 消息发送到何处。

标签: ios objective-c nsmutablearray


【解决方案1】:

上述异常是在待添加对象为nil时引起的。你能验证_geofences_ending_regions[_positionOfRoute] 是否不为零吗?

【讨论】:

  • 是的,它不是 nil,因为我在前面的代码行中使用了它。我认为初始化发生了一些事情,但我无法找出问题所在。
猜你喜欢
  • 2015-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-09-28
相关资源
最近更新 更多