Reputation: 261
I am experiencing frequent crashing that I believe is related to this method of checking the number of MIDINetwork Sessions.
- (NSString*) describeConnections {
NSMutableArray* connections = [NSMutableArray arrayWithCapacity:1000];
for (MIDINetworkConnection* connection in [[MIDINetworkSession defaultSession] connections]) {
[connections addObject:[[connection host] name]];
}
if ([connections count] > 0) {
return [connections componentsJoinedByString:@", "];
}
else
return @"(Not connected)";
}
When the app crashes it stops on the line
for (MIDINetworkConnection* connection in [[MIDINetworkSession defaultSession] connections])
The error I am getting is
Thread 1: EXC_BAD_ACCESS(code=EXC_1386_GPFLT)
In the debugger it shows
_impl _MIDINetworkConnectionImpl * NULL
I have tried to prevent the crashing by checking if MIDINetworkSession is NULL before looping through the connections but that hasn't worked. Occasionally when xcode crashes it will stop at
int main(int argc, char *argv[])
{
@autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, nil);
return retVal;
}
}
Can anyone offer a guess as to what's happening?
Upvotes: 0
Views: 172
Reputation: 593
It seems that connections contain NULL, in some case the system dealloc the connections.But in the set, it cannot use the NULL to be elements, so you should check the connections or use the try catch to get the exception.
Upvotes: 1