NSURLConnection delegate methods are not called

后端 未结 4 856
借酒劲吻你
借酒劲吻你 2020-12-04 17:51

I am trying to create a simple NSURLConnection to communicate with a server using a GET request. Connection works well, but delegates methods of NSURLConnection are never ca

4条回答
  •  没有蜡笔的小新
    2020-12-04 18:04

    Try running the operation on main thread:

    NSURLConnection * connection = [[NSURLConnection alloc] 
                                    initWithRequest:request
                                           delegate:self startImmediately:NO];
    
    [connection scheduleInRunLoop:[NSRunLoop mainRunLoop] 
                          forMode:NSDefaultRunLoopMode];
    [connection start];
    

提交回复
热议问题