|
Hi all, I'm implementing a "DetailedUserView" for the Dore Data challenge part (day 61) This view contains a generic FilteredList (form Core Data technique project, Project 12 part 2) for Friends of the current User. To this list I will pass a predicate to retrieve from database the complete information for all Friends, so in the init for my DetailedUserView I prepare everything I need to pass dow to this generic list view:
(wr and wp prefixes indicate that these are wrapping-computed-properties/relationship to not deal with the optionals from Core Data, as in Creating NSManagedObject subclasses, added as extensions to the generated cclasses) The probem is that the app crashes when entering the DetailUserView with the error:
The example for this type of predicate is at https://nspredicate.xyz/#predicate-format-and-arguments
Curiously: if I use the predicate from the example above (without the label argumentArray:) I got the error:
which seems to consider the whole array... ...but if I use the Predicate with the label argumentArray: I get the error:
which seems to consider ony the first element of the array :-) I tried also with strings (converting the UUID or using user name) but I always get this error. Did anyone met and solved this error? Is there another simple way to filter Core Data objects to fetch only those with an attribute value contained in an array/set/collection ? I can give acess to my complete code on gitHub if needed (not public by defaut because I'm, code-shy:-)), let me know |
|
Try casting the |
|
Hi @roosterboy, thanks for your sugestion! I'm not sure I got it right, did you mean somethig like ?
? This gives an error and the compiler suggests to fix by casting to [Any], so I ended up like this:
Unfortunately, it doesn't solved the problem, same crash. Somehow I expected this since I already tried using the friend name (String) instead of its id (UUID):
with the same results (also trierd to apply your casting here, same result). However this was useful because by doing this I noticed an error in my code: I was using wpID (or wpName) in the predicate, but these are my computed vars... I should have used id or name instead , the original properties of the entity. So I corrected like this:
And i got a different error:
the same happen if i apply your suggestion again (cast to CVarArg and Any). I'm stuck, this exception is even more obscure than the previous :-) |
|
Solved, apparently I didn't try everything in the right combnation: using properties from generated classes (not the wrapping ones) in the predicate AND removing the label
from the predicate initializer works! Still confused however, I'd like to know the root cause since that argument label is also in Apple official docuentation |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.