在我们的iPhone应用程序中,NSURLConnection请求暂时出现了间歇性问题.它似乎发生得更晚了.一旦进入此状态,它就会保持该状态.唯一的决议似乎是杀死应用程序并重新启动它.
观察:
其他杂项:
如下所示,代码在主线程上运行.我假设有一些东西在该线程上阻塞,但是我在暂停应用程序时看到的堆栈跟踪表明主线程没问题.我认为NSURLConnection正在使用自己的线程,必须阻止它.
#define relnil(v) (v = nil)
- (id) initWebRequestController
{
self = [super init];
if (self)
{
//setup a queue to execute all web requests on synchronously
dispatch_queue_t aQueue = dispatch_queue_create("com.myapp.webqueue", NULL);
[self setWebQueue:aQueue];
}
return self;
}
- (void) getStuffFromServer
{
dispatch_queue_t aQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_async(aQueue, ^{
dispatch_sync([self webQueue], ^{
error_block_t errorBlock = ^(MyAppAPIStatusCode code, NSError * error){
dispatch_async(dispatch_get_main_queue(), ^{ …Run Code Online (Sandbox Code Playgroud)