出现NSScanner: nil string argument libc++abi.dylib: terminate_handler unexpectedly threw an exception

出现了

2015-04-04 20:12:51.501 Pan大夫[5001:299704] NSScanner: nil string argument

2015-04-04 20:12:51.502 Pan大夫[5001:299704] NSScanner: nil string argument

libc++abi.dylib: terminate_handler unexpectedly threw an exception

的错误信息的总结:

出现了这种错误我当时实在找不到好的方法,后来我才发现:

原来是我的传进的 NSString 类型的变量为空了,原来是我在代码块中使用了局部变量,导致后来退出代码块时,内存销毁,

导致内存为空。

解决方法是:

1.避免使用:NSString* string = string2;

2.避免使用:NSString* string1 = [NSString stringWithFormat:@""];的形式

3.在代码块中,一定要考虑,内存是否提前被销毁:

对于变量:最好使用:

NSString* string1 = [NSString alloc] initWithFormat:@"%@", string2];

的形式

//以上是我自己的见解,不足请指正,谢谢。 --- 小红旗

QQ- 651134397

时间: 2024-08-25 00:40:33

出现NSScanner: nil string argument libc++abi.dylib: terminate_handler unexpectedly threw an exception的相关文章

libc++abi.dylib: terminate_handler unexpectedly threw an exception错误小结

前言 我们在运行xcode工程时,有时候会遇到”libc++abi.dylib: terminate_handler unexpectedly threw an exception”错误,app莫名其妙就crash掉了,在控制台输入bt命令,查看调用堆栈,结果也是一头雾水: 分析 现在唯一的信息点是libc++abi.dylib,这个库到底是做什么的?从后缀看,是一个动态库,那么会不会是因为发生了一些动态错误?而按经验来看,一般的动态错误基本是因为动态类型错误引起,在object-c语言中,会发

综合出现NSScanner: nil string argument libc++abi.dylib: terminat错误的解决方案

在开发中出现了这个错误,断点查找很久,没找到问题所在的代码,google下,发现了下面这几点会产生这个错误: 首先,顾名思义,错误原因是我们在调用某个方法的时候,传入了一个空字符串(注意区别于字符串内容为空)作为方法参数. 对某一个空数组使用objectAtIndex方法.不会报数组越界的错,而是NSScanner: nil string argument. 经过检查,我代码中如果字符串赋值,我一般都对nil做了一定处理,用@""代替,也未有数组越界,但是还是报这样的错误. 现在的信息

libc abi.dylib: terminate_handler unexpectedly threw an exception

错误代码:很明显的错误,一定要谨记. 1 - (NSInteger)giftCountFullScreen{ 2 NSArray *arr = [NSMutableArray arrayWithArray:self.arrayGiftGruop]; 3 for (id data in arr) { 4 BaseGiftItem *item = (BaseGiftItem *)data; 5 if ([item.image isEqualToString:@"gift_bamboo"]

libc++abi.dylib: terminate_handler unexpectedly错误

http://my.oschina.net/ioslighter/blog/384328 今天测试app时发现一个必现的异常,当在登录成功后再打开登录前点击的页面时,就会在Xcode console中打印如下日志: NSScanner:nil string argumentNSScanner:nil string argumentlibc++abi.dylib: terminate_handler unexpectedly threw an exception 然后app就会crash掉. 搜索

IOS Exception 1(libc++abi.dylib: terminating with uncaught exception of type NSException)

2014-08-05 22:18:46.455 SwiftUI[1329:40871] -[_TtC7SwiftUI14MViewControler clickMe]: unrecognized selector sent to instance 0x10ea15dc0 2014-08-05 22:18:46.458 SwiftUI[1329:40871] *** Terminating app due to uncaught exception 'NSInvalidArgumentExcept

错误代码报错--0x000000010b801145 start + 1 ) libc++abi.dylib: terminating wit

问题描述:在做搜索栏实验的时候,一点击搜索按钮就停止运行 还有报错代码是: 0x000000010b801145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) singnal SIGABRT 0x109d60580:  movq   0xb53449(%rip), %rax      ; (void *)0x000000010b8f3070: __stack_

解决iOS的libc++abi.dylib: handler threw exception问题

今天遇到了libc++abi.dylib: handler threw exception的问题,不过在真机上运行一切正常!一开始没有想到是由于模拟器对xib文件的编译缓存,需要把模拟器中的App删除,同时把代码clean一次,再编译运行,终于一切正常了. 问题的根本原因是由于之前xib中有个控件的连接对象有问题,后来修改了,但编译器没有识别出来,总是不对新xib进行处理,导致模拟器总是报错! 以后遇到奇怪的问题,可以使用此法先确定不是环境的问题,再着手在代码中查找吧! 解决iOS的libc++

错误代码报错--0x000000010b801145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

问题描述:在做搜索栏实验的时候,一点击搜索按钮就停止运行 还有报错代码是: 0x000000010b801145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) singnal SIGABRT   0x109d60580:  movq   0xb53449(%rip), %rax      ; (void *)0x000000010b8f3070: __stac

libc++abi.dylib handler threw exception

在iOS开发时,有时候遇到libc++abi.dylib handler threw exception这样的异常,  虽然在断点出加上了All Exceptions,也断到相应的代码了,但是没打印对应的日志,实际上不是这段代码的问题.因此不知道什么地方出错了.这时候可以用下面的代码来打印异常log @try{ // 要执行的代码 } @catch(NSException *exception) { NSLog(@"exception:%@", exception); } @final