I tried send it by fileTransfer method:
let modelURL = NSBundle.mainBundle().URLForResource("my_app", withExtension: "momd")!
WCSession.defaultSession().transferFile(modelURL, metadata:nil)
but I get error:
Optional(Error Domain=WCErrorDomain Code=7008 "Invalid parameter passed to WatchConnectivity API." UserInfo={NSLocalizedDescription=Invalid parameter passed to WatchConnectivity API., NSLocalizedRecoverySuggestion=Only pass parameters of correct type.})
Do you have any idea how to sync CoreData between iPhone and WatchOS2?
You are trying to send the entire “momd” directory. The transfer file API of WatchConnectivity does not seem to support transferring directories, and is therefore returning an error in -session:didFinishFileTransfer:error:
To resolve this problem you have a couple of options:
Solution number 2 is probably the best one as it allows you to send only the changes that have been made instead of the entire database each time a change is made, but will be more work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With