This is Apple's code
- (BOOL)removeConnection: (MIDINetworkConnection *)connection;
in
-[MIDINetworkSession removeConnection:]
yet it results in an EXC_BAD_ACCESS
. This only happens in iOS 9.
Any help or workarounds?
This is Apple's code
- (BOOL)removeConnection: (MIDINetworkConnection *)connection;
in
-[MIDINetworkSession removeConnection:]
yet it results in an EXC_BAD_ACCESS
. This only happens in iOS 9.
Any help or workarounds?
It's the
MIDINetworkConnection
that's gettingdealloced
and causing the issue.The workaround that I'm using is that I add these objects to an
NSMutableArray
before callingremoveConnection:
(mine is calledconnectionsThatHaveBeenClosed
;) ). Unfortunately, I have to keep this array growing until the App is closed, which is a leak.Yar's answer helped me, except it doesn't cover the case where a disconnection happens from the other device. Instead of storing the objects to an array in removeConnection: I have a manager object that listens to the MIDINetworkNotificationSessionDidChange notification, looks for any new connections, and adds the references to an NSMutableSet.
So, in my manager init I have:
... and my sessionChanged: method:
That seems like a fast way to figure out how to store a reference to each connection, no matter who initiated it. Then when the connection is removed (either by your app, or the other device), the reference is already stored, and no crash!