Post

Replies

Boosts

Views

Activity

Reply to SwiftData: Accessing collection from computed property forces dependency update ?!? and this compute property and so on... cycle
workaround @Model final class Item { var name: String var id: UUID @Relationship(deleteRule:.cascade, inverse: \Entry.item) var entries: [Entry] init(name: String) { self.name = name self.id = UUID() entries = [] } } extension Item { private var _entries: [Entry]? { return try? self.context?.fetch(FetchDescriptor<Entry>(predicate:#Predicate<Entry>{ $0.item.id == id},sortBy: [SortDescriptor(\Entry.date, order: .forward)])) } } extension Item { func checkingDate()->Date?{ let _ = _entries //... return Date() } } But is really awkward not allowed directly to access the collection property inside one entity...
Aug ’23
Reply to swiftdata insert(_) runs synchronously?
in MainActor
Replies
Boosts
Views
Activity
Aug ’23
Reply to SwiftData: Accessing collection from computed property forces dependency update ?!? and this compute property and so on... cycle
https://github.com/quaternionboy/LifeKPIs-SwiftData-Data-Model/tree/Profiling-LifeKPIs-Tests
Replies
Boosts
Views
Activity
Aug ’23
Reply to SwiftData: Accessing collection from computed property forces dependency update ?!? and this compute property and so on... cycle
https://github.com/quaternionboy/LifeKPIs-SwiftData-Data-Model
Replies
Boosts
Views
Activity
Aug ’23
Reply to SwiftData: Accessing collection from computed property forces dependency update ?!? and this compute property and so on... cycle
https://github.com/quaternionboy/LifeKPIs-SwiftData-Data-Model
Replies
Boosts
Views
Activity
Aug ’23
Reply to SwiftData. Predicate. Issue accessing self (Entity) inside a Predicate
yes, works
Replies
Boosts
Views
Activity
Aug ’23
Reply to SwiftData: Accessing collection from computed property forces dependency update ?!? and this compute property and so on... cycle
workaround @Model final class Item { var name: String var id: UUID @Relationship(deleteRule:.cascade, inverse: \Entry.item) var entries: [Entry] init(name: String) { self.name = name self.id = UUID() entries = [] } } extension Item { private var _entries: [Entry]? { return try? self.context?.fetch(FetchDescriptor<Entry>(predicate:#Predicate<Entry>{ $0.item.id == id},sortBy: [SortDescriptor(\Entry.date, order: .forward)])) } } extension Item { func checkingDate()->Date?{ let _ = _entries //... return Date() } } But is really awkward not allowed directly to access the collection property inside one entity...
Replies
Boosts
Views
Activity
Aug ’23
Reply to SwiftData inverse Relationship stop working in XCode 15 beta 7
Making Item optional fixes the problem: var item: Item?
Replies
Boosts
Views
Activity
Aug ’23