|
Hi everyone, I've been fighting with SwiftData for the past few days without reaching an understanding. I have to say I'm just a beginner so I may have made mistakes somewhere else too, but still I don't understand. So, what I'm trying to do is to have a list of For organizing the code I took inspiration from Apple's sample code.
|
|
Hi there! Two points that catch my eye in the code.
or even like this.
|
|
@ygeras yes, the categories having a reference to the words is something I didn't need in this very initial code but I'll consider it now, thanks. As per the main issue, both solutions you propose are something I had read about online and tried already, unfortunately that doesn't seem to work either (I tried again exactly as you suggested with no luck). Anyway, I think I'll just query all words at the same time and filter them later as I was already thinking, this solution just does not seem to work. |
|
In predicate, try to compare NOT category to category, BUT String to String. This approach works for sure, see sample below:
|
|
Ah yes, now this works. I had in fact tried both of the approaches before but perhaps never at the same time: I had tried to compare strings and not objects and I had tried using local variables, but probably I never tried doing both. I did find it weird that no solution seemed to work. Thanks for the help, I'll now consider which approach is better, also considering your suggestion of the inverse relationship! EDIT: I did end up using this, so thank you very much! |
SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.