Fix crash on physical device
This commit is contained in:
		| @@ -3,4 +3,38 @@ | ||||
|    uuid = "2238B32A-BF80-4351-B121-F5E36A8C39FC" | ||||
|    type = "1" | ||||
|    version = "2.0"> | ||||
|    <Breakpoints> | ||||
|       <BreakpointProxy | ||||
|          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||||
|          <BreakpointContent | ||||
|             uuid = "B690606A-775E-4310-8057-014628DF0882" | ||||
|             shouldBeEnabled = "No" | ||||
|             ignoreCount = "0" | ||||
|             continueAfterRunningActions = "No" | ||||
|             filePath = "Toki Trainer/Views/ContentView.swift" | ||||
|             startingColumnNumber = "9223372036854775807" | ||||
|             endingColumnNumber = "9223372036854775807" | ||||
|             startingLineNumber = "39" | ||||
|             endingLineNumber = "39" | ||||
|             landmarkName = "body" | ||||
|             landmarkType = "24"> | ||||
|          </BreakpointContent> | ||||
|       </BreakpointProxy> | ||||
|       <BreakpointProxy | ||||
|          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||||
|          <BreakpointContent | ||||
|             uuid = "A4ACF1DD-9390-41EC-9DB6-3B2DEBF59EFD" | ||||
|             shouldBeEnabled = "No" | ||||
|             ignoreCount = "0" | ||||
|             continueAfterRunningActions = "No" | ||||
|             filePath = "Toki Trainer/Views/ContentView.swift" | ||||
|             startingColumnNumber = "9223372036854775807" | ||||
|             endingColumnNumber = "9223372036854775807" | ||||
|             startingLineNumber = "59" | ||||
|             endingLineNumber = "59" | ||||
|             landmarkName = "body" | ||||
|             landmarkType = "24"> | ||||
|          </BreakpointContent> | ||||
|       </BreakpointProxy> | ||||
|    </Breakpoints> | ||||
| </Bucket> | ||||
|   | ||||
| @@ -16,7 +16,7 @@ struct ContentView: View { | ||||
|     @Environment(\.managedObjectContext) private var viewContext | ||||
|      | ||||
|     @ObservedObject var tokiDictViewModel = TokiDictionaryViewModel() | ||||
|     @State private var selectedPartOfSpeech: String? = nil | ||||
|     @State private var selectedPartOfSpeech: String? | ||||
|     @State private var tokiInput: String = "" | ||||
|      | ||||
|     var body: some View { | ||||
| @@ -64,7 +64,7 @@ struct ContentView: View { | ||||
|                 .background(.thinMaterial) | ||||
|             } | ||||
|             .sheet(item: $selectedPartOfSpeech) { selectedPOS in | ||||
|                 PartsOfSpeechView(selectedPartOfSpeech: selectedPOS, tokiDictViewModel: self.tokiDictViewModel) | ||||
|                 PartsOfSpeechView(selectedPartOfSpeech: selectedPOS, partsOfSpeech: tokiDictViewModel.partsOfSpeech) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -10,7 +10,9 @@ import SwiftUI | ||||
| struct PartsOfSpeechView: View { | ||||
|     var selectedPartOfSpeech: String? = nil | ||||
|      | ||||
|     @ObservedObject var tokiDictViewModel: TokiDictionaryViewModel | ||||
|     @ObservedObject var tokiDictViewModel = TokiDictionaryViewModel() | ||||
|      | ||||
|     var partsOfSpeech: [TokiPartOfSpeech] | ||||
|      | ||||
| //    init(selectedPartOfSpeech: String) { | ||||
| //        _selectedPartOfSpeech = State(initialValue: selectedPartOfSpeech) | ||||
| @@ -32,7 +34,7 @@ struct PartsOfSpeechView: View { | ||||
|                         Spacer() | ||||
|                     } | ||||
|                     //.background(.blue) | ||||
|                     .background((selectedPartOfSpeech == pos.pos) ? Color(UIColor.systemGray4) : .white) | ||||
|                     .background((selectedPartOfSpeech == pos.pos) ? Color(UIColor.systemGray4) : Color(UIColor.systemBackground)) | ||||
|                     .cornerRadius(5.0) | ||||
|                     .padding(2) | ||||
|                 } | ||||
| @@ -44,6 +46,7 @@ struct PartsOfSpeechView: View { | ||||
|  | ||||
| struct PartsOfSpeechView_Previews: PreviewProvider { | ||||
|     static var previews: some View { | ||||
|         PartsOfSpeechView(selectedPartOfSpeech: "sep", tokiDictViewModel: TokiDictionaryViewModel()) | ||||
|         PartsOfSpeechView(selectedPartOfSpeech: "sep", partsOfSpeech: [TokiPartOfSpeech(pos: "sep", definition: "test")]) | ||||
|             .preferredColorScheme(.dark) | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user