Saturday, February 17, 2024
HomeiOS Developmentios - Ought to SwiftData to-many relationships even be elective for CloudKit?

ios – Ought to SwiftData to-many relationships even be elective for CloudKit?


Contemplating CloudKit, ought to tags array be elective?

@Mannequin
last class Merchandise {

    let title: String = ""
    let subtitle: String = ""

    @Relationship(deleteRule: .cascade, inverse: TagModel.merchandise)
    let tags: [TagModel] = []?
}

Or an empty array is ample?

@Mannequin
last class Merchandise {

    let title: String = ""
    let subtitle: String = ""

    @Relationship(deleteRule: .cascade, inverse: TagModel.merchandise)
    let tags: [TagModel] = []
}

I perceive that relationships should be elective, as CloudKit syncs information non-atomically. So our code ought to anticipate some relations not at all times obtainable. But I am unsure about arrays (to-many relationships). It appears that evidently simply by utilizing an array that may be empty, we’re already anticipating some relations not at all times obtainable.

How did you implement to-many SwiftData relationships contemplating CloudKit?



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments