Post

Replies

Boosts

Views

Activity

Reply to SwiftData #Predicate cannot test for nil relationship
func query(group: Group) { let id = group.id let predicate = #Predicate<Item> { item in item.group?.id == id // Compiles } } @MarcusAurelius This method can indeed compile, but when I use similar code to run, the following error message will appear: Thread 1: Fatal error: Couldn't find \Tag.id on Tag with fields May I ask if your code can use the above predicate to fetch data?
Topic: App & System Services SubTopic: iCloud Tags:
Sep ’23
Reply to Hot to merge Predicate in SwiftData
Thank you for your reply. However, in some cases, I need to prepare some predicates in advance and combine them according to some conditions during the running of the app. This is also the main use of NSCompoundPredicate in this situation. However, in the new Predicate, no similar mechanism is provided. I feel that PredicateExpression may provide a corresponding method, but I haven't found it yet.
Topic: App & System Services SubTopic: iCloud Tags:
Aug ’23
Reply to ModelActor Implementation Changes In Xcode 15 Beta 7
@ModelActor actor CountryModelActor { init(container: ModelContainer) { modelContainer = container let context = ModelContext(container) modelExecutor = DefaultSerialModelExecutor(modelContext: context) } func newItem() { let item = Item(timestamp: .now, name: "\(Int.random(in: 0...3))") modelContext.insert(item) try! modelContext.save() } }
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’23
Reply to SwiftData #Predicate cannot test for nil relationship
func query(group: Group) { let id = group.id let predicate = #Predicate<Item> { item in item.group?.id == id // Compiles } } @MarcusAurelius This method can indeed compile, but when I use similar code to run, the following error message will appear: Thread 1: Fatal error: Couldn't find \Tag.id on Tag with fields May I ask if your code can use the above predicate to fetch data?
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Sep ’23
Reply to Hot to merge Predicate in SwiftData
Thank you for your reply. However, in some cases, I need to prepare some predicates in advance and combine them according to some conditions during the running of the app. This is also the main use of NSCompoundPredicate in this situation. However, in the new Predicate, no similar mechanism is provided. I feel that PredicateExpression may provide a corresponding method, but I haven't found it yet.
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to ModelActor Implementation Changes In Xcode 15 Beta 7
@ModelActor actor CountryModelActor { init(container: ModelContainer) { modelContainer = container let context = ModelContext(container) modelExecutor = DefaultSerialModelExecutor(modelContext: context) } func newItem() { let item = Item(timestamp: .now, name: "\(Int.random(in: 0...3))") modelContext.insert(item) try! modelContext.save() } }
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’23