|
Hi, Disclaimer : I'm a newbie with Swift / SwiftUI, please be kind :) I have a DatesEntity, in relationship with a TraitementEntity and a SymptomeEntity : So each Dates could have several treatments (traitement in French) with each its hour (heureSansDates) or symptoms (symptome in French) with each its hour I have a "Journal" like that : where each row with "bolt.heart.fill" symbol, is a Symptom (Symptome) and each row with "pills.fill" symbol, is a Treatment (Traitement) done with :
The problem is when I want to show Only treatments, sectionned by Date, I have empty sections that appears (because, even If there is no treatment for this date, there could be a symptom for this date...)
in : TraitementEntity+CoreDataProperties.swift I have declared :
(for better explaination, here is the Journal for symptoms only) @delawaremathguy tried to help me in another thread but I can't make it work, so I figured I'll make a new thread with better explaination Any help is appreciated :) Thanks |
|
Looking at your examples of the symptoms and treatment entries, what can I see in the text is that on every day you have at least one symptom, but not necessarily a treatment. By this I mean that every date has a symptom, so does not show an expected output, because they are show irrespective of whether or not a treatment was recorded. Here is an example based on a sample code in the Xcode documentation for
You could create an appropriate conditional to skip empty treatments, or empty symptoms, for the dates. |
|
Thanks a lot for your answer ! I didn't know you could do that, so thanks I finally just used a predicate in my SectionedFetchRequest and it worked
|
|
Yes, you can use a predicate for the fetchRequest, and that will limit what is fetched based on the predicate. (As an aside you may also want to learn how to use compound predicates, to use with logic such as Looking at your buttons ( It is your app, either way works, so whatever works for you is great. |
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.