EXC_BAD_ACCESS(code = 2)on [[NSDateFormatter alloc] init] [英] EXC_BAD_ACCESS(code=2) on [[NSDateFormatter alloc] init]

查看:171
本文介绍了EXC_BAD_ACCESS(code = 2)on [[NSDateFormatter alloc] init]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从iOS 5.1我得到 EXC_BAD_ACCESS(代码= 2)错误当我实例化NSDateFormatter对象。

Since iOS 5.1 I'm getting EXC_BAD_ACCESS(code=2) errors when I instantiate an NSDateFormatter object.

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; // bad_access
[dateFormatter setDateFormat:@"dd.MM.yyyy"];

有没有人体验到类似的东西,或者甚至有解决方案?这让我疯了!
我对我的项目使用ARC。

Did anyone experience something similar or maybe even has a solution? It's making me crazy! I'm using ARC for my project.

编辑:

甚至 NSDateFormatter * dateFormatter = [NSDateFormatter new]; 给我同样的错误。

推荐答案

我以前有一些类似的问题。普通100%无错行导致此EXC_BAD_ACCESS,代码= 2,僵尸显示什么。
事情是我有一个死循环,以某种方式调用函数A 再次调用函数A 这导致再次调用函数A 等(在堆栈跟踪有一个looooot行)。所以我只是耗尽了内存和EXC_BAD_ACCESS。防止代码进入死亡循环解决了我。

I've had some similar problems some time ago. Ordinary 100%-error-free line causes this EXC_BAD_ACCESS, code=2, zombies show nothing. The thing was that I had a death cycle, somehow calling function A caused calling function A again, that caused calling function A again and so on (at the stack trace there were a looooot of lines). So I've just ran out of memory and got EXC_BAD_ACCESS. Preventing code to enter that death loop solved that for me.

希望这有助。

这篇关于EXC_BAD_ACCESS(code = 2)on [[NSDateFormatter alloc] init]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆