2013-02-08 40 views
1

可能有人请告诉我这是什么意思:错误,同时运行的iPhone应用程序帮助 - __NSCFConstantString错误含义

2013-02-08 11:19:49.394 xxxxx[10545:907] set selected tab with tag 3 
2013-02-08 11:19:49.560 xxxxx[10545:907] did select item 
2013-02-08 11:19:49.562 xxxxx[10545:907] tab clicked 
2013-02-08 11:19:49.566 xxxxx[10545:907] will show view controller MoreViewController 
2013-02-08 11:19:49.567 xxxxx[10545:907] will show other VC 

2013-02-08 11:19:49.579 xxxxx[10545:907] -[__NSCFConstantString offImage]: unrecognized selector sent to instance 0x21994c 
2013-02-08 11:19:49.580 xxxxx[10545:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString offImage]: unrecognized selector sent to instance 0x21994c' 

我只是想修改一些代码,但是这些修改没有工作。所以按下z并解开了我修改的所有内容,但是现在我收到了这个错误。

+0

您可能正在为已释放/释放的对象调用一个方法,并且其内存空间区域现在由不执行该方法的新(不同)对象/实例使用:您有一个“Zombie” – meronix 2013-02-08 16:38:33

回答

2

“无法识别的选择器发送到实例”错误总是意味着一件事:你在不支持它的实例上调用方法。在这种特殊情况下,你在你的代码行,看起来像这样:

[someObject offImage]; 

在此行中,someObject是字符串,它不具有offImage方法的一个实例。

这个问题可以通过传递一个错误类型的对象,以其他方法引起的:

[someTarget objectWithOffImage:@"Hello"]; 

的方法,可以期待的是响应offImage一个对象,但你传递一个字符串。

最后,您可能试图调用类别中的方法,但是您忘记导入该类别的头文件。

+0

嗯,这很奇怪。我在这里调用[item offImage]: static NSString * CellIdentifier = @“Cell”; UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil){cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; // Set cell style } TabBarItem * item = _moreItems [indexPath.row]; cell.imageView.image = [item offImage]; \t cell.textLabel.text = item.title; return cell; 所以实例不支持offImage? – 2013-02-08 16:50:54

+1

@SulaimanMajeed这意味着'_moreItems [indexPath.row]'指向一个字符串对象。当'indexPath.row'的值大于数组的大小时,或者当数组有一个悬挂指针时(例如用于指向已被解除分配的对象,以及用于存储已经被其他对象重用,在这种情况下,对于一个常量字符串)。 – dasblinkenlight 2013-02-08 17:28:23

+0

我发现_moreItems [indexPath.row]指向内存中无效的位置。我仍然不确定为什么有一个晃来晃去的指针。我试图找出悬挂指针的起源地。你帮我找到了我的错误的根源。感谢您的帮助和明确的答案! – 2013-02-08 18:01:36

0

您正在将消息-offImage发送到NSString的实例,该实例没有该名称的方法。改变你的代码,以便-offImage被发送到正确的对象类型

相关问题