GTLServiceYouTube executeQuery callback not called

允我心安 提交于 2019-12-20 04:38:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!