Post

Replies

Boosts

Views

Activity

SwiftData Relationship
I have 2 classes and a relationship from one to another... I am getting an error while runtime. Can someone help me with this issue??.. @storageRestrictions(accesses: _$backingData, initializes: _trans) init(initialValue) { _$backingData.setValue(forKey: \.trans, to: initialValue) _trans = _SwiftDataNoType() } get { _$observationRegistrar.access(self, keyPath: \.trans) return self.getValue(forKey: \.trans) } set { _$observationRegistrar.withMutation(of: self, keyPath: \.trans) { self.setValue(forKey: \.trans, to: newValue) } } } Thread 1: EXC_BREAKPOINT (code=1, subcode=0x25256ead8) Below is my class... import SwiftData @Model final class Main { var name: String var limit: Double @Relationship(deleteRule: .cascade) var trans: [Child] = [] init(name: String, limit: Double, trans: [Child]) { self.name = name self.limit = limit self.trans = trans } } @Model final class Child { var trip: String var distance: Double init(trip: String, distance: Double) { self.trip = trip self.distance = distance } }
2
0
1.1k
Oct ’23
Large title missing while returning from navigation view
I have a tool bar with a picker and the navigation bar title is set to large. The initial screen is ok, but once I navigate to the detailed view and return to the main screen, my title is missing. I am unable to find an answer. Kindly help. var body: some View {         NavigationView {             VStack {                 TabView(selection: $choice,                         content:  {                             OPListCell()                             IPListCell()                         })                     .tabViewStyle(PageTabViewStyle())             }             .listStyle(PlainListStyle())             .navigationBarTitle(Text("My Patients"), displayMode: .large)             .toolbar {                 ToolbarItem(placement: .principal) {                     HStack {                         Picker(selection: self.$choice, label: Text("")) {                             ForEach(0 ..< self.choices.count) {                                 Text(self.choices[$0])                             }                         }                         .frame(width: 175)                         .pickerStyle(SegmentedPickerStyle())                         .padding(.leading, 10)                     }                 }             }         }     } }
0
1
295
Jan ’21