Post

Replies

Boosts

Views

Activity

How to define a generic SwiftUI view that can accept sectioned fetch results for different entities
I need to define a generic SwiftUI view that can accept sectioned fetch results for different CoreData entities, but I'm not sure how to define the generic view. In the example below, I have two sectioned fetch results defined for Patient and Doctor entities. I need to be able to pass them to the generic view. @SectionedFetchRequest( sectionIdentifier: \.sectionTitle, sortDescriptors: Patient.nameSortDescriptors(), animation: .default) private var patients: SectionedFetchResults<String, Patient> @SectionedFetchRequest( sectionIdentifier: \.sectionTitle, sortDescriptors: Doctor.nameSortDescriptors(), animation: .default) private var doctors: SectionedFetchResults<String, Doctor> GenericView(items: patients) GenericView(items: doctors) struct GenericView: View { let items: ????? }
2
0
1.5k
Feb ’22
SwiftUI CompactDatePickerStyle Erratic Formatting Behavior
Using the following DatePicker code, dates are displayed with two different formats, either MMM, D YY or M/D/YY. It should always display MMM, D YY, but randomly displays M/D/YY after changing the date via the calendar interface. import SwiftUI struct ContentView: View {     @State var date = Date()     var body: some View {         DatePicker(             "On Date",             selection: $date,             displayedComponents: .date)             .datePickerStyle(CompactDatePickerStyle())     } }
0
0
488
Mar ’21