Getting further into testing my NSOperationQueue-ified code on iOS (after working around the problem I reported earlier today), I’m finding that the NSURLConnection delegate methods are not being called at all. Ever. Which is kind of a showstopper, and I’ve run out of ideas for debugging/troubleshooting, since there isn’t much visibility into what CFNetwork is doing behind the scenes. To recap:
I’ve created a global NSOperationQueue to serialize access to the code that runs TouchDB, a NoSQL database, since the code is not thread-safe. This code ends up starting asynchronous NSURLConnections to communicate with other servers. I’m setting the connection’s queue to my queue so the delegate methods will still be called: _connection = [[NSURLConnection alloc] initWithRequest: _request delegate: self startImmediately: NO]; [_connection setDelegateQueue: [NSOperationQueue currentQueue]]; [_connection start]; Yes, I’ve verified that +currentQueue returns my queue, since it’s being invoked from it. On Mac OS X 10.7.3, everything is working fine. On iOS 5.1, the connection object is created and started, but no delegate method ever gets called, nor does the connection ever get cancelled or released. So something is Very Wrong Indeed. The rest of the app is running fine; the main thread is alive and handling events. The internal CFNetwork thread is idle. All other threads are idle, and I can’t find any thread associated with my queue. The queue object is still around, and has no operations queued in it.
Any ideas? I’d hate to have to back out all of this refactoring and go back to messing around on the CFNetwork thread, but if I can’t make this work on iOS I’m going to have to do just that.
—Jens
|