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
.