Thank you very much @ctrlswift! I currently do not have any use for CloudKit sharing in my project and it's only for iOS and watchOS, not macOS.
Trying to find an effective way to setup CoreData so that it coexists with SwiftData as suggested. If someone has any link that would point me in the right direction for doing so, I would be most grateful.
It's a bit of a bummer that that's the only way to do it though, as I do not need CoreData for any purpose at all other than getting the user name, since all the persistence is handled by SwiftData/CloudKit.
Cheers,
Jorge
Post
Replies
Boosts
Views
Activity
Also not working for me..."child" objects are not being deleted when using the .cascade option. Could someone be abe to assist?
I'm using SwiftData with CloudKit enabled. Here's a simplified version of my model, where Score objects are not being deleted upon deletion of Match objects :
import SwiftData
@Model
class Match {
// CloudKit integration requires all relationship properties to be optional
@Relationship(deleteRule: .cascade, inverse:\Score.match) var score: Score?
init() {
self.score = Score(
startServing: true,
decidingSetType: .regular
)
}
}
@Model
class Score {
// CloudKit integration requires all relationship properties to be optional
var match: Match?
// CloudKit integration requires all non optional properties to have a default value
let startServing: Bool = true
let decidingSetType: DecidingSetType = DecidingSetType.regular
init(
startServing: Bool,
decidingSetType: DecidingSetType
) {
self.startServing = startServing
self.decidingSetType = decidingSetType
}
}
enum DecidingSetType: Codable {
case regular
case superTiebreak
}
Sorry @SkinSoftware but I'm having the same problem and I'm not shure I understand how you did it. In my case it should be even simpler because I'm using only on single App swift file for Apple Watch and iOS.
In my case I'm seeing two different data sets, one for iPhone and another for Apple Watch, but my intention is to have only one. Would you or someone bee able to explain how to use the same data in iOS and Apple Watch, using SwiftData and CloudKit?
Any hint/help would be much appreciated.