EXC_BAD_ACCESS (code = 2) in [[NSDateFormatter alloc] init]
As of iOS 5.1, I am getting errors EXC_BAD_ACCESS(code=2)
when creating an NSDateFormatter object.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; // bad_access
[dateFormatter setDateFormat:@"dd.MM.yyyy"];
Has anyone experienced something similar or maybe even had a solution? It makes me crazy! I am using ARC for my project.
EDIT:
Even NSDateFormatter* dateFormatter = [NSDateFormatter new];
gives me the same error.
source to share
I had some similar problems a while ago. The usual 100% fail-safe line calls this EXC_BAD_ACCESS, code = 2, the zombies show nothing. The thing is, I had a death loop, calling function A
again function A
, which caused the call function A
again and so on (there were looooot lines on the stack trace). So I just ran out of memory and got EXC_BAD_ACCESS. Preventing code from being entered into this death loop solved it for me.
Hope it helps.
source to share