1

I am following the Build a Mobile App With Sync tutorial MongoDB provides but running into an error when configuring the sync on a particular collection. This is my code:

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)

These are my imports:

import MongoSwift
import StitchCore
import StitchRemoteMongoDBService

And for clarity's sake, here is the error: enter image description here

I have some theories, like a separate import required or my XCode indexing is just broken, but no success so far.

Edit: I am using pod 'StitchSDK', '~> 5.0.0'

Robbie Cronin
  • 1,557
  • 2
  • 10
  • 15

1 Answers1

4

I have installed that pod and found you need to add

import StitchCoreRemoteMongoDBService

And DefaultConflictHandlers is renamed with DefaultConflictHandler

So after importing your code will be:

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)
Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
  • 2
    yeah import removed the error, however the new method call looks like this: `DefaultConflictHandler.remoteWins()` Everything is running smoothly now, thanks. – Robbie Cronin Mar 12 '19 at 07:04