我正在尝试将 react-native 应用程序转换为 chromecast。chromecast GCKDeviceScanner 必须在主线程上运行。
反应本机页面说要在主线程上运行,您必须这样做:
- (dispatch_queue_t)methodQueue
{
return dispatch_get_main_queue();
}Run Code Online (Sandbox Code Playgroud)
I am not very familiar with swift or ios, so where do I put this code, and how do I use it? I have my method:
let filterCriteria = GCKFilterCriteria(forAvailableApplicationWithID: "myApp")
let deviceScanner = GCKDeviceScanner(filterCriteria: filterCriteria)
if let deviceScanner = deviceScanner {
deviceScanner.addListener(self)
deviceScanner.startScan()
deviceScanner.passiveScan = true
}Run Code Online (Sandbox Code Playgroud)
Any idea on how I can run my code on the main thread?