'NSInvalidArgumentException',原因:' - [__ NSArrayM标识符]:无法识别的选择器发送到实例0x9f996a0'

时间:2013-09-13 21:40:13

标签: ios objective-c nsmutablearray

上述错误发生在这一行:

  _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' 

1 个答案:

答案 0 :(得分:0)

当要添加的对象为nil时,会导致上述异常。你能核实_geofences_ending_regions[_positionOfRoute]是不是零吗?