问题
GTLServiceYouTube executeQuery
callback not called when I execute it in background thread.Video wont get uploaded. It works fine when I execute it in main thread.I get callbacks and video is also uploaded. I can solve this by forcing executeQuery
to run in main thread but that affects the UI performance. How can I solve this issue?
My code goes like this ,
self.uploadFileTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLYouTubeVideo *uploadedVideo,
NSError *error) {
// code to handle
}
回答1:
I found a solution! Here whats happening is, when I run the code in background thread, before the callback comes the thread is detached. Hence we don't get the callback. When I run it in main thread, main Thread remains alive throughout. Hence we do get callback. Hence this problem can be solved by making current thread to wait using following code.
[[NSRunLoop currentRunLoop] runUntilDate:stopDate];
来源:https://stackoverflow.com/questions/28541282/gtlserviceyoutube-executequery-callback-not-called