我的类文件myFile是继承UIViewController的(目的是为了能够在一个view里切换不同的tableView),在myFile.h中定义一个可变数组editContactsList,然而在IB里面添加了一个view,两个tableView,在下面方法里面报错(有注明具体位置)
-
(void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath*)indexPath
{
if (editingStyle
== UITableViewCellEditingStyleDelete)
{
// Delete the row from the data
source.
NSUInteger row =
[indexPath row];
[tableView beginUpdates];
NSLog(@"%@",self.editContactsList);//打印到数组内容
[self.editContactsList removeObjectAtIndex:row];//此处报错,错误信息在下面
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[tableView endUpdates];
[tableView reloadData];
}
}
错误信息:
***
Terminating app due to uncaught exception ‘NSInvalidArgumentException‘, reason:
‘-[__NSArrayI removeObjectAtIndex:]: unrecognized selector sent to instance
0x5e88f90‘
*** Call stack at first
throw:
(
0 CoreFoundation
0x0214ebe9
__exceptionPreprocess + 185
1 libobjc.A.dylib
0x022a35c2
objc_exception_throw + 47
2 CoreFoundation
0x021506fb
-[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3
CoreFoundation
0x020c0366 ___forwarding___ + 966
4
CoreFoundation
0x020bff22 _CF_forwarding_prep_0 + 50
5
Etisalat
0x0014cb39 -[GMViewController
tableView:commitEditingStyle:forRowAtIndexPath:] + 211
6
UIKit
0x014232ea
-[UITableView(UITableViewInternal) animateDeletionOfRowWithCell:] +
101
7 UIKit
0x013b9a6e
-[UIApplication sendAction:to:from:forEvent:] + 119
8
UIKit
0x014481b5 -[UIControl
sendAction:to:forEvent:] + 67
9 UIKit
0x0144a647 -[UIControl(Internal) _sendActionsForEvents:withEvent:]
+ 527
10 UIKit
0x014491f4
-[UIControl touchesEnded:withEvent:] + 458
11 UIKit
0x013de0d1 -[UIWindow _sendTouchesForEvent:] +
567
12 UIKit
0x013bf37a
-[UIApplication sendEvent:] + 447
13 UIKit
0x013c4732 _UIApplicationHandleEvent +
7576
14 GraphicsServices
0x0328ba36 PurpleEventCallback +
1550
15 CoreFoundation
0x02130064
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ +
52
16 CoreFoundation
0x020906f7 __CFRunLoopDoSource1 +
215
17 CoreFoundation
0x0208d983 __CFRunLoopRun +
979
18 CoreFoundation
0x0208d240 CFRunLoopRunSpecific
+ 208
19 CoreFoundation
0x0208d161 CFRunLoopRunInMode +
97
20 GraphicsServices
0x0328a268 GSEventRunModal +
217
21 GraphicsServices
0x0328a32d GSEventRun +
115
22 UIKit
0x013c842e
UIApplicationMain + 1160
23 **(这里代表工程名)
0x0013c914 main +
114
24
**(这里代表工程名)
0x00004081 start +
53
)
terminate called after throwing an
instance of ‘NSException‘
Program received signal:
“SIGABRT”.
(gdb)
麻烦各位大侠帮忙看看,指点指点,本人菜鸟,被它搞到头大了,谢谢
谢谢!确实是这个原因。
我在viewDidLoad里面这样为editContactsList赋值:
NSMutableArray
*arr =[ [NSArray alloc]
initWithObjects:@"a",@"b",@"c",nil];
self. editContactsList
= arr;
[arr
release];
就会出现上面的错误,后来改成了下面的方法就通过了:
NSArray *arr
= [[NSArray alloc]initWithObjects:@"a",@"b",@"c",nil];
[NSMutableArray
arrayWithCapacity:10];
[editContactsList setArray:arr];
[arr
release];
转:http://www.cocoachina.com/bbs/simple/?t67161.html
__NSArrayI removeObjectAtIndex:]: unrecognized selector sent to instance,布布扣,bubuko.com
__NSArrayI removeObjectAtIndex:]: unrecognized selector sent to instance
原文地址:http://www.cnblogs.com/ygm900/p/3742643.html