Apple rejected my app due to crash, can't reproduce it

限于喜欢 提交于 2019-12-05 12:17:13

You crashed inside objc_msgSend with an EXC_BAD_ACCESS exception. In my experience this probably means that an object has gone out of scope and you're trying to access it or, the object is supposed to do something on another thread and in the mean time (while it's doing that), its gone out of scope on the original thread.

If you're using one of Apple's multithreaded objects (pretty much anything with delegate callbacks), make sure it is retained (strong-ly) by the object in which it is contained. For example if you're using an object with asynchronous callbacks, you can't just instantiate it inside a method and then let it disappear, you have to make it a strong @property so it remains in scope even when the method returns and you are awaiting the callbacks.

EDIT (Based on CFSocket thread):

By the look of it, you're using a socket API which is commonly used with the NSStream class. Remember to create strong @properties for those NSStream objects (or other connection objects you are using), and, if you're wrapping them inside another object, make sure that it is a strong @property of whichever object is using it. You can't get an asynchronous callback from an object that's not there anymore on the thread that created it.

(Note this is not just a case of messaging an object that has been set to nil. Messages to nil do not crash, they just return nil. The issue is a message being sent to something in memory that you don't own anymore).

EDIT 2 (based on main thread):

Are you sure you own every object that is being used in the View Controller transition? Creating a transient object in a block or asynchronous action could also be causing the EXC_BAD_ACCESS.

From what it looks like, may be two threads are accessing the same variables where one of the threads is corrupting the variables used in the other. It is a synchronization issue. Bad access mostly means you are accessing a variable that is nil

You can integrate a crash reporting tool like www.crashlytics.com in your application. It is very easy to implement and the documentation is available once you download the sdk. After implementation, test your app throughly and it will tell you the exact lines where your code crashes and you can resolve it.

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