Thread 1: EXC_BAD_ACCESS (code=1, address=0xf00000c)

强颜欢笑 提交于 2020-01-12 13:45:15

问题


I have problem with Thread 1: EXC_BAD_ACCESS (code=1, address=0xf00000c) and I don't know how to resolve it. It appeared when I change some object in core date and save it and I try to pop this controller to parent. This error is in main() with retVal. here is some code

        int retVal;
    @try {
        retVal =  UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
           */\ error is here**
    }
    @catch (NSException *exception) {
        NSLog(@"%@", [exception callStackSymbols]);
        @throw exception;
    }
    return retVal;

After re-runing app all my changes are in core data. What is more this problem is only on iOS 7. iOS 6.1 is ok.

Does someone have idea how to resolve it?


回答1:


As a comment said this error is likely to be deep in your code. If the culprit is a zombie, the easiest way to find it is to run it (preferably in the latest Xcode, currently Xcode 5, as it has been improved) in profiler and choose "Zombies". When it fails, you can see the history of everything that has happened to the object.

Also, set an exception breakpoint. You may get a break when the error happens instead of in main, where the exception gets passed up.




回答2:


I resolved this problem with "Zombies" and the problem was with [UIScrollView(UIScrollViewInternal) _notifyDidScroll]

I added

- (void)dealloc {

  self.tableView.delegate = nil;

} 

This problem was only in iOS 7.

Thanks for help!




回答3:


I have resolve this issue only by debugging the source code and re-analyze my logic.

Below are some reference that help me lot.

EXC_BAD_ACCESS means that message was sent to a point in the memory where there’s no instance of a class to execute it. Thus “bad access”.

You will get EXC_BAD_ACCESS in 3 cases:

  • An object is not initialized
  • An object is already released
  • Something else that is not very likely to happen

That’s already a good starting point. Start using the debugger, if you recently added a new object to the class you’re working on, put a breakpoint at the line before the freshly added object is used for the first time and check the values in the debugger.

What’s happening most though is that you will be sending a message to an overreleased object – i.e. object that is gone from the call stack. In this cases everything (and indeed everything) you will get in the console will be just :EXC_BAD_ACCESS

This is because the object is gone, there is no information what class was it, or what source file or anything else.

Please try to avoid using zombies for this.




回答4:


EXC_BAD_ACCESS means there is no instance of a class to execute it.

There are 2 or more possibilities:

  1. An object is not initialized
  2. An object is already released

Please debug application carefully and analyze each object carefully. That might solve your issue.




回答5:


I solved the same problem by finding out that the name of one of my NSString variables had the same name as one of the frameworks' class variables. Took seconds to change the name a little and problem disappeared.

With such a huge number of class variables in frameworks, it is very likely that once in a while, every programmer just by coincidence names some variable in his class exactly the same as one used somewhere in framework classes. So it doesn't have to be Xcode bug in most cases.




回答6:


In my case, I was using third-party library and I forgot to set custom-class name in Storyboard Identity Inspector




回答7:


And there may be another issue which I faced today: I had a mutable dictionary with a non-object entry try. There was a code snippet with adding a BOOL value to the dictionary. So no wonder that I got this error =).




回答8:


I just had the exact same problem.

Looked here and found nothing so I started backtracking until I thought, maybe I should try Clean Build Folder🤔

I was glad it was as easy as CLEAN BUILD FOLDER!!!

Product- Clean Build Folder(⇧ ⌘ K)

😀



来源:https://stackoverflow.com/questions/19183555/thread-1-exc-bad-access-code-1-address-0xf00000c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!