同样是删除cell问题,帮我看看问题出现在哪,谢谢!

我的类文件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) 


麻烦各位大侠帮忙看看,指点指点,本人菜鸟,被它搞到头大了,谢谢

引用第1楼coco89718于2011-07-19 11:00发表的  :
你用的是NSArray吗,要用NSMutableArray。
如果头文件定义的editContactsList是NSMutableArray类型,那在初始化的时候是不是
self.editContactsList = [[NSArray alloc] init]把他初始化成了NSArray呢 

谢谢!确实是这个原因。
我在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的更多相关文章

  1. -[__NSArrayI removeAllObjects]: unrecognized selector sent to instance 0x7fa8dc830110

    问题 今天做项目,遇到了这个问题 -[__NSArrayI removeAllObjects]: unrecognized selector sent to instance 0x7fa8dc8301 ...

  2. iOS 程序报错:reason: [NSArrayI addObject:]: unrecognized selector sent to instance

    *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI ad ...

  3. '-[__NSCFString stringFromMD5]: unrecognized selector sent to instance 0x14d89a50'

    类型:ios 问题描述: 导入百度地图 然后在模拟器运行可以,真机测试不行: 报错: '-[__NSCFString stringFromMD5]: unrecognized selector sen ...

  4. unrecognized selector sent to instance

    今天长一见识(特此感谢小星星老湿-坏笑),凡是遇到“unrecognized selector sent to instance *******”的都是******方法没有,比如这种的错误: 可以尝试 ...

  5. IOS 错误 [UIWebView cut:]: unrecognized selector sent to instance

    那在什么场景中会出现这种情况呢? 如果一个包含文字的输入元素有焦点,然后按钮的点击会导致输入失去焦点,然后接下来在输入时双按会重新得到焦点并从弹出bar中选择剪切复制粘贴,就会导致此error. 也就 ...

  6. -[__NSCFNumber length]: unrecognized selector sent to instance 0xb0000000000000e3

    网络数据解析出现-[__NSCFNumber length]: unrecognized selector sent to instance 0xb0000000000000e3这样的错误,具体 re ...

  7. CBUUID UUIDString unrecognized selector sent to instance 错误

    CBUUID UUIDString unrecognized selector sent to instance 错误 ios7.0,4s 蓝牙出现上述错误! 查看api可知,错误原因,由于CBUUI ...

  8. reason: -[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance

    reason: -[UIKBBlurredKeyView candidateList]: unrecognized selector sent to instance 发现上线的app一直会有这个cr ...

  9. 利用objc的runtime来定位次线程中unrecognized selector sent to instance的问题

    昨天遇到一个仅仅有一行错误信息的问题: -[NSNull objectForKey:]: unrecognized selector sent to instance 0x537e068 因为这个问题 ...

随机推荐

  1. 如何计算 App 的启动时间

    应用启动场景 事实上 Android 中一个 App 的启动时间可以准确计算的.但是要分场景.也就是说要分开游戏和应用. 大家都知道,在Android中,游戏开发和应用开发是两码事.所以我们需要分开来 ...

  2. Java 连接远程Linux 服务器执行 shell 脚本查看 CPU、内存、硬盘信息

    pom.xml jar 包支持 <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch& ...

  3. 使用配置文件启动MongoDB

    Ubuntu 16.04 (阿里云ECS),MongoDB 4.0, 原来,已经写了10篇MongoDB的随笔了.可是,自己居然没有使用配置文件启动过MongoDB,对其更多的配置是不明白的. 昨天( ...

  4. KNN算法的感受 2

    (1):先将上述代码保存为kNN.py (2):再在IDLE下的run菜单下run一下,将其生成python模块 (3):import  kNN(因为上一步已经生成knn模块) (4):kNN.cla ...

  5. java 通过异常处理错误

    java的基本理念是"结构不佳的代码不能够运行" 一.概念 发现错误的理想时机是编译阶段,然而,编译期间并不能找出所有的错误,余下的问题必须在运行时期解决. 二.基本异常 异常情形 ...

  6. Java编程的逻辑 (59) - 文件和目录操作

    本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...

  7. IDEA & Android Studio换主题背景

    IDEA系列主题 http://www.riaway.com/index.phphttp://color-themes.com/?view=index 详细用法: https://www.jiansh ...

  8. AndroidStudio3.0以上版本的坑

    原文:https://blog.csdn.net/ytfunnysite/article/details/78864556 1.Error:Failed to resolve: com.android ...

  9. 迷茫于Hibernate/JPA的人提一些建议。

    想对那些“迷惑”于Java ORM框架的J2EE开发人员提一些建议,希望能够对他们 更深入的理解和运用J2EE ORM框架来提速工作有所帮助,这些建议可能显得有些”陈旧“和”肤浅“, 因为最近半年我没 ...

  10. 利用HTML5定位功能,实现在百度地图上定位(转)

    原文:利用HTML5定位功能,实现在百度地图上定位 代码如下: 测试浏览器:ie11定位成功率100%,Safari定位成功率97%,(add by zhj :在手机上测试(用微信内置浏览器打开),无 ...