Post

Replies

Boosts

Views

Activity

Reply to Attribute being read has no value: 768444
I changed it like this (still get errors) GroupBox { HStack { TextField("Have a goal?", text: $saveGoal.bound) .keyboardType(.numberPad) Spacer() Button("Save"){ UserDefaults.standard.set(self.saveGoal, forKey: "Save") self.hideKeyboard() } } Foe example if I open the textfield and press save without filling the textfield, sometimes it crashes Or if I close the window while the TextFiled is active
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Attribute being read has no value: 768444
It happens on a real device This problem occurs when I close the window without writing anything or tapping done, and other times it crashes just when I close the app I think this is the real error: 2020-12-29 13:31:50.645517+0100 Nums[2002:352091] [error] precondition failure: attribute being read has no value: 785340 AttributeGraph precondition failure: attribute being read has no value: 785340. (lldb) I also get this when I separate the iPhone from the Mac: warning: failed to set breakpoint site at 0x1a2116b1c for breakpoint -5.1: error sending the breakpoint request (lldb) @State private var saveGoal = UserDefaults.standard.string(forKey: "Save")
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Fetch JSON Data not working
2020-12-28 14:36:28.125962+0100 Charts[47870:4787368] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed 2020-12-28 14:36:28.201001+0100 Charts[47870:4787265] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want.  Try this:  (1) look at each constraint and try to figure out which you don't expect;  (2) find the code that added the unwanted constraint or constraints and fix it.  (     "<NSLayoutConstraint:0x600002f2fe30 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x7f86e8424430]-(6)-[_UIModernBarButton:0x7f86e8421fd0'API']   (active)>",     "<NSLayoutConstraint:0x600002f2fe80 'CB_Trailing_Trailing' _UIModernBarButton:0x7f86e8421fd0'API'.trailing <= _UIButtonBarButton:0x7f86e8411020.trailing   (active)>",     "<NSLayoutConstraint:0x600002f0cc80 'UINav_static_button_horiz_position' _UIModernBarButton:0x7f86e8424430.leading == UILayoutGuide:0x60000351f1e0'UIViewLayoutMarginsGuide'.leading   (active)>",     "<NSLayoutConstraint:0x600002f0ccd0 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x7f86e8411020]-(0)-[UILayoutGuide:0x60000351f100'UINavigationBarItemContentLayoutGuide']   (active)>",     "<NSLayoutConstraint:0x600002f3d950 'UINavItemContentGuide-trailing' UILayoutGuide:0x60000351f100'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x7f86e8610bf0.trailing   (active)>",     "<NSLayoutConstraint:0x600002f0d450 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x7f86e8610bf0.width == 0   (active)>",     "<NSLayoutConstraint:0x600002f3dd10 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x60000351f1e0'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UINavigationBarContentView:0x7f86e8610bf0 )>" ) Will attempt to recover by breaking constraint  Error: <NSLayoutConstraint:0x600002f2fe30 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x7f86e8424430]-(6)-[_UIModernBarButton:0x7f86e8421fd0'API']   (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. failure(Swift.DecodingError.valueNotFound(Swift.Int, Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 3", intValue: 3), CodingKeys(stringValue: "deathConfirmed", intValue: nil)], debugDescription: "Expected Int value but found null instead.", underlyingError: nil)))
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Fetch JSON Data not working
I still don't get an error but I can't see any data Code: // //&#9;Charts // //&#9;Created by Jad on 08/12/20. // import SwiftUI import Combine struct ContentView: View { &#9;&#9;@ObservedObject var networkController = NetworkController() &#9;&#9;@State var search: String = "" &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;NavigationView{ &#9;&#9;&#9;&#9;&#9;&#9;Form{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Section(){ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;TextField("Search", text: $search) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Section(){ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;if search.isEmpty{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;List(networkController.users, id: \.self){ user in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink(destination: DetailView(positive: user.positive, state: user.state, deathConfirmed: user.deathConfirmed)){ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text(user.state) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} else{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;List(networkController.users.filter{$0.state.contains(search)}, id: \.self){ user in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink(destination: DetailView(positive: user.positive, state: user.state, deathConfirmed: user.deathConfirmed)){ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text(user.state) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;.navigationTitle("API") &#9;&#9;&#9;&#9;} &#9;&#9;} } class NetworkController: ObservableObject { &#9;&#9;private var can: AnyCancellable? &#9;&#9; &#9;&#9;let url = URL(string: "https://api.covidtracking.com/v1/states/current.json")! &#9;&#9;@Published var users = [User(state: "", positive: 0, deathConfirmed: 0)] &#9;&#9; &#9;&#9;init() { &#9;&#9;&#9;&#9;self.can = URLSession.shared.dataTaskPublisher(for: url) &#9;&#9;&#9;&#9;&#9;&#9;.map { $0.data } &#9;&#9;&#9;&#9;&#9;&#9;.decode(type: [User].self, decoder: JSONDecoder()) &#9;&#9;&#9;&#9;&#9;&#9;//.replaceError(with: []) &#9;&#9;&#9;&#9;&#9;&#9;.eraseToAnyPublisher() &#9;&#9;&#9;&#9;&#9;&#9;.receive(on: DispatchQueue.main) &#9;&#9;&#9;&#9;&#9;&#9;.sink(receiveCompletion: {completion in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print(completion) &#9;&#9;&#9;&#9;&#9;&#9;}, receiveValue: { users in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.users&#9;= users &#9;&#9;&#9;&#9;&#9;&#9;}) &#9;&#9;} &#9;&#9; } struct User: Decodable, Hashable { &#9;&#9;var state: String &#9;&#9;var positive: Int &#9;&#9;var deathConfirmed: Int } struct DetailView: View { &#9;&#9; &#9;&#9;var gridItemLayout = [GridItem(.flexible()), GridItem(.flexible())] &#9;&#9; &#9;&#9;var positive: Int &#9;&#9;var state: String &#9;&#9;var deathConfirmed: Int &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;ScrollView{ &#9;&#9;&#9;&#9;&#9;&#9;LazyVGrid(columns: gridItemLayout, spacing: 10){ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;GroupBox{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;VStack{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("State: ") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Divider() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text(String(state)) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;.cornerRadius(16) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}.padding() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;GroupBox{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;VStack{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("Positive: ") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Divider() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text(String(positive)) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;.cornerRadius(16) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}.padding() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;GroupBox{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;VStack{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text("State: ") &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Divider() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text(String(deathConfirmed)) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;.cornerRadius(16) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}.padding() &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;.navigationBarTitle(state) &#9;&#9;&#9;&#9;} &#9;&#9;} } ```
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Fetch JSON Data not working
Still not working (I changed some code) // //&#9;Charts // //&#9;Created by Jad on 08/12/20. // import SwiftUI import Combine struct ContentView: View { &#9;&#9;@ObservedObject var networkController = NetworkController() &#9;&#9;@State var search: String = "" &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;NavigationView{ &#9;&#9;&#9;&#9;&#9;&#9;Form{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Section(){ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;TextField("Search", text: $search) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Section(){ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;if search.isEmpty{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;List(networkController.users, id: \.self){ user in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink(destination: DetailView(positive: user.positive, deathConfirmed: user.deathConfirmed)){ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text(user.state) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} else{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;List(networkController.users.filter{$0.state.contains(search)}, id: \.self){ user in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink(destination: DetailView(positive: user.positive, deathConfirmed: user.deathConfirmed)){ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text(user.state) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;.navigationTitle("API") &#9;&#9;&#9;&#9;} &#9;&#9;} } class NetworkController: ObservableObject { &#9;&#9;private var can: AnyCancellable? &#9;&#9; &#9;&#9;let url = URL(string: "https://api.covidtracking.com/v1/states/current.json")! &#9;&#9;@Published var users = [User(state: "", positive: 0, deathConfirmed: 0)] &#9;&#9; &#9;&#9;init() { &#9;&#9;&#9;&#9;self.can = URLSession.shared.dataTaskPublisher(for: url) &#9;&#9;&#9;&#9;&#9;&#9;.map { $0.data } &#9;&#9;&#9;&#9;&#9;&#9;.decode(type: [User].self, decoder: JSONDecoder()) &#9;&#9;&#9;&#9;&#9;&#9;.replaceError(with: []) &#9;&#9;&#9;&#9;&#9;&#9;.eraseToAnyPublisher() &#9;&#9;&#9;&#9;&#9;&#9;.receive(on: DispatchQueue.main) &#9;&#9;&#9;&#9;&#9;&#9;.sink(receiveValue: { users in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;self.users&#9;= users &#9;&#9;&#9;&#9;&#9;&#9;}) &#9;&#9;} &#9;&#9; } struct User: Decodable, Hashable { &#9;&#9;var state: String &#9;&#9;var positive: Int &#9;&#9;var deathConfirmed: Int } //struct Records: Decodable, Hashable { //&#9;&#9;var countriesAndTerritories: String //}
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Decoding JSON SwifUI
Hello And I have another question about the decimalPad &#9;&#9;@State var deci = 3      var numberFormatter: NumberFormatter = {          let nf = NumberFormatter()          nf.locale = Locale.current          nf.numberStyle = .decimal          nf.maximumFractionDigits = deci          return nf      }() How do I fix this at line 10: Instance member 'deci' cannot be used on type 'BMIView'; did you mean to use a value of this type instead? Thank you very much for your time
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Decoding JSON SwifUI
This is the file now: [   {     "title": "Shapes",     "items": [       "rectangle",       "rectangle.fill",       "shield",       "shield.fill"     ]   },   {     "title": "Arrows",     "items": [       "arrowshape.turn.up.left",       "arrowshape.turn.up.left.fill",       "arrowshape.turn.up.left.circle",       "arrowshape.turn.up.left.circle.fill"     ]   } ]
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Decoding JSON SwifUI
Hello I tried your solution and got this: Thread 1: Fatal error: Failed to decode sf.json from bundle.: keyNotFound(CodingKeys(stringValue: "id", intValue: nil), Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: \"id\", intValue: nil) (\"id\").", underlyingError: nil))
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20