I am compiling a static library (FAT binary) that includes the following:
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
NSOperationQueue *queue = [[NSOperationQueue alloc] init]; // also tried [NSOperationQueue mainQueue]
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
// CRASH BEFORE BLOCK EXECUTES
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
...
The code in itself runs fine if compiled with the app on a device and the simulator but it crashes when used as a static library in another app ONLY on the simulator. The static library works fine on an iOS device. The crash is a EXC_BAD_ACCESS
and by doing some logging, I narrowed it down to the sendAsynchronousRequest
. The block does not get called.
Any idea what could be wrong?
I was able to fix it by using the NSURLConnectionDelegate
methods instead. I am still curious to know why it was crashing, please do comment if you have any ideas.