NSInternalInconsistencyException Missing visible cell to setup animations VipServicePlatform dzn_original_implementation (UIScrollView+EmptyDataSet.m:)

解决方案

内部矛盾异常,断言评估一个条件,如果条件为 false ,调用当前线程的断点句柄。每一个线程有它自已的断点句柄,它是一个 NSAsserttionHandler 类的对象。当被调用时,断言句柄打印一个错误信息,该条信息中包含了方法名、类名或函数名。然后,它就抛出一个 NSInternalInconsistencyException 异常。

NSInternalInconsistencyException,从它的字面意思来看的话,是不一致导致的,下面就一些例子

1. NSMutableDictionary的错误使用

比如把NSDictionary当做NSMutableDictionary来使用,从他们内部的机理来说,就会产生一些错误,NSMutableDictionary中有很多NSDictionary不支持的接口

[objc] view plain copy 在CODE上查看代码片派生到我的代码片

NSString *result = @"{\"username\”:\”aaa\”,\"phone\":\"15666666666\",\"bankcount\":\"98765432112345678\"}";   

NSData *data = [result dataUsingEncoding:NSUTF8StringEncoding];   

NSMutableDictionary *info = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];   

if (info) {   

    NSString *username = [Utils UrlDecode: info[@"username"]];   

    [info  setObject:username forKey:@"username"];   

}   

执行上述代码后报错:

[objc] view plain copy 在CODE上查看代码片派生到我的代码片

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'   

出错原因在于:

[objc] view plain copy 在CODE上查看代码片派生到我的代码片

[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil]; 

返回的结果是immutable对象,不能直接对immutable进行赋值操作,否则会报错。

修改后代码:

[objc] view plain copy 在CODE上查看代码片派生到我的代码片

NSString *result = @"{\"username\”:\”aaa\”,\"phone\":\"15666666666\",\"bankcount\":\"98765432112345678\"}";   

NSData *data = [result dataUsingEncoding:NSUTF8StringEncoding];   

//----将immutable转换为mutable----   

NSDictionary *temp = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];   

NSMutableDictionary *info = [NSMutableDictionary dictionaryWithDictionary:temp];   

//----------------------   

if (info) {   

    NSString *username = [Utils UrlDecode:info[@"username"]];   

    [info  setObject:username forKey:@"username"];   

}   

2. 界面使用不当

[objc] view plain copy 在CODE上查看代码片派生到我的代码片

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 

eason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ViewController'' 

其中一个原因是:

在AppDelegate.m的- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中使用xib文件初始化,但程序的入口是storyboard,didFinishLaunching不需要写东西

self.viewController = [[ViewController alloc] initWithNibName: @"ViewController" bundle: nil];

工程里面没有ViewController.xib,初始化出错。

3.Constant is not finite! That's illegal. constant:nan'

除数为0时候崩溃

4. failed to obtain a cell from its dataSource

CellIdentifier I bet your cellForRowAtIndexPath is returning null.

应该避免cellForRowAtIndexPath 返回的cell为空

5.对象为nil,不存在

[MASViewConstraint setSecondViewAttribute:],nil调用约束方法导致崩溃

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 面试题参考1 : 面试题[http://www.cocoachina.com/ios/20150803/12872...
    江河_ios阅读 1,762评论 0 4
  • 对这门课程从好奇、半信半疑到满怀期待,随着日子临近,就这么享受着整个过程。 提问 老师让每个人自我介绍并提问,我的...
    金钱宝宝阅读 236评论 0 1
  • 运用之妙存乎一心(诸葛亮大能安邦定国小能修身齐家) 每次都是有两条以上的选择 哪些是好的主意 哪些是坏的主意? 需...
    福v慧阅读 142评论 0 0
  • (1) 今天在《实现梦想时,什么会发生呢?》这本书上看到这句话,顿时有种眼前一亮的感觉。 我随即思考:为什么作者会...
    Jessie_Tan阅读 562评论 3 5