gpt4 book ai didi

swift - 使用未解析的标识符 'DefaultConflictHandlers'

转载 作者:搜寻专家 更新时间:2023-11-01 06:25:48 25 4
gpt4 key购买 nike

我正在关注 Build a Mobile App With Sync教程 MongoDB 提供但在特定集合上配置同步时遇到错误。这是我的代码:

todoCollection.sync.configure(
conflictHandler: DefaultConflictHandlers.remoteWins.resolveConflict,
changeEventDelegate: { documentId, event in
if !event.hasUncommittedWrites {
// you can add code here to update your app's UI or
// perform other operations based on a document change.
}
}, errorListener: self.on)

这些是我的进口:

import MongoSwift
import StitchCore
import StitchRemoteMongoDBService

为了清楚起见,这里是错误: enter image description here

我有一些理论,比如需要单独导入或者我的 XCode 索引刚刚被破坏,但到目前为止没有成功。

编辑:我正在使用 pod 'StitchSDK', '~> 5.0.0'

最佳答案

我已经安装了那个 pod,发现你需要添加

import StitchCoreRemoteMongoDBService

并且 DefaultConflictHandlers 重命名为 DefaultConflictHandler

因此在导入您的代码后将是:

todoCollection.sync.configure(
conflictHandler: DefaultConflictHandler.remoteWins.resolveConflict,
changeEventDelegate: { documentId, event in
if !event.hasUncommittedWrites {
// you can add code here to update your app's UI or
// perform other operations based on a document change.
}
}, errorListener: self.on)

关于swift - 使用未解析的标识符 'DefaultConflictHandlers',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55115264/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com