我正在尝试在iOS的cordova插件中使用mongodb mobile。在mongodb mobile中,一个所谓的客户端用于连接数据库。我想将此客户端全局存储在我的swift类中,以便其他功能可以访问它。当我这样做时,打开应用程序后,我会在运行时出错。
我是新手,很快。
错误:
Service exited due to signal: Segmentation fault: 11 sent by exc handler[0]
这是我的快速代码:
import StitchCore
import StitchLocalMongoDBService
@objc(MongoDBStorage) class MongoDBStorage : CDVPlugin {
var client: StitchAppClient?
@objc(initiate:)
func initiate(command: CDVInvokedUrlCommand){
var pluginResult = CDVPluginResult(
status: CDVCommandStatus_ERROR
)
do {
client = try Stitch.initializeDefaultAppClient(
withClientAppID: "appid"
)
print("succes")
pluginResult = CDVPluginResult(
status: CDVCommandStatus_OK,
messageAs: "initiate succes"
)
} catch {
print("error")
pluginResult = CDVPluginResult(
status: CDVCommandStatus_ERROR,
messageAs: "Unexpected error: \(error)."
)
}
self.commandDelegate!.send(
pluginResult,
callbackId: command.callbackId
)
}
}