2016-11-08 45 views

回答

1

科尔多瓦的官方文件指出:

如果你的插件需要处理大量或者需要一个阻塞调用,你应该使用一个后台线程。

用你这样的代码:

- (void)myPluginMethod:(CDVInvokedUrlCommand*)command 
{ 
    // Check command.arguments here. 
    [self.commandDelegate runInBackground:^{ 
     NSString* payload = nil; 
     // Some blocking logic... 
     CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:payload]; 
     // The sendPluginResult method is thread-safe. 
     [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 
    }]; 
} 
+0

感谢您的回答。但我试过了!没有解决。 – beginner