1

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

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

为了清楚起见,这里是错误: 在此处输入图像描述

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

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

4

1 回答 1

4

我已经安装了那个 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)
于 2019-03-12T06:37:31.667 回答