Connection delegate methods not called with background thread, Why ? (iPhone SDK)
Connection delegate methods not called with background thread, Why ?
In program i have created background thread and that thread set connectio开发者_开发知识库n delegates, by setting ObjNSURLConnection.delegate = AnotherClass, and that AnotherClass contains NSURLConnection delegate methods.
But when i debug a code i have found that NSURLConnection delegate method doesn't called. Any reason , Why they are not called ? How to solve this issue?
NSURLConnection
schedules notifications for events on the runloop on which it was called. You are likely neglecting to run the runloop for your background thread.
You need to explicitly run the runloop after starting the connection. Try adding this line of code
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
精彩评论