All Questions
18
questions
0
votes
1
answer
24
views
Predicate macro doesn't build with Array.contains()
DocumentModel contains tags relationship to TagModel. A View receives selectedTag. Predicate (as part of @Query) should filter documents that have given tag.
let selectedTag = TagModel()
#Predicate&...
0
votes
0
answers
24
views
How do I create a List Section based on an empty related field in SwiftData?
I have three models in SwiftData - a parent Event related to Group and Item. I have a list of all Items by Group that belong to a specific Event. But I can't figure out how to list the Items that ...
1
vote
1
answer
90
views
Getting a compiler error trying to write a complicated Predicate - Scenario 2
This is an additional scenario for the question and answer covered here.
Sample code is available here.
Original problem was related to this predicate:
let aPred = #Predicate<Event> {
...
2
votes
1
answer
177
views
Getting a compiler error trying to write a complicated Predicate
I know there are similar questions out there, like this one for example Combining Predicate in SwiftData but all that looks unnecessary complex to me and I find it difficult to believe that there is ...
1
vote
1
answer
127
views
How to create "ENDSWITH" predicate for SwiftData @Query?
I can create all kinds of predicates fine, but I'm not sure what can I use for implement "ENDSWITH"?
extension Filter {
var predicate: Predicate<WordModel>? {
switch self {...
1
vote
1
answer
250
views
SwiftData predicate when a relationship is optional
Consider the following relationship in SwiftData:
@Model
class Category: Decodable, Identifiable {
var id: Int
var title: String
@Relationship var questions = [Question]()
}
@Model
...
0
votes
0
answers
44
views
How to form a search predicate with one to many model
I have a Company and a Certificate model. Each Company can have many Certificates. There is a one to many relationship.
I cannot figure out how to form a predicate that will fetch all the certificates ...
0
votes
1
answer
220
views
Predicate expression not compiling because of complexity
I am displaying quite a lot of data in a SwiftUI view, the data is stored in SwiftData and it's working fine, the problem is when I need to filter the data. Below code is a simpler version of the ...
0
votes
1
answer
420
views
Swift #Predicate with function usage on the argument
Is it possible to use a #Predicate that part of its expression calls a function (trying to pass that predicate into a SwiftData Query):
func myPredicate(year: Int, month: Int) -> Predicate<MyObj&...
4
votes
0
answers
430
views
SwiftData Predicate with Many to Many Relationship
I'm building a Photo managing app that uses tags to help filter images. I decided to use SwiftData since it makes syncing images via CloudKit super easy. However, I'm having trouble fetching photos ...
4
votes
0
answers
493
views
SwiftData - Predicate does not support keypaths with multiple components
I have [Word] to [Folder], and Word to Card relationships. I can fetch all words for folder, but i can't fetch all cards for folder. It says Predicate does not support keypaths with multiple ...
0
votes
0
answers
1k
views
Issues filtering items in SwiftData with Query and Filter
I am attempting to implement SwiftData and I am getting errors but only after running the code and the errors are inside the expansion of the macro 'Query'
The errors are:
Attribute 'private' can ...
9
votes
3
answers
3k
views
Combining Predicate in SwiftData
I'm trying to combine multiple Predicates of the Type with and / or.
Previously with CoreData and NSPredicate I'd just do this:
let predicate = NSPredicate(value: true)
let predicate2 = NSPredicate(...
2
votes
1
answer
2k
views
SwiftData search bar and predicate
I'm trying to create a view using the SwiftData framework with a search bar where the user can type a registration of an airplane and dynamically update the list. But first I'm not sure if I'm doing ...
3
votes
2
answers
1k
views
Does the #Predicate macro in Foundation/SwiftData support case-insensitive search?
I'm testing the new SwifData framework and working with the new #Predicate macro and realized that it doesn't support case-insensitive search. The macro does not work with the lowercased() method or ...