![]() ![]() A View.environmentObject(_:) for QuizSettings may be missing as an ancestor of this view. Thread 1: Fatal error: No ObservableObject of type QuizSettings found. The specific error thrown is about not finding the EnvironmentObject Ancestor View. (Which also need their own State/Observed/Object variables?) If you know how to fix my issue, please include "the fix" for these Preview sections too? Text(oupName) //!! THIS IS WHERE THE ERROR IS THROWING!Īlso keep in mind each of the 3 files above have a "Preview" section that ALSO has to be free of errors. Struct HeaderView: View var userInput: QuizSettings I have a larger ContentView() file (not shown) that has HeaderView() in a VStack. NOTE: This is an "inner view," - a file just to create the "header" of my app.A Button and some static footer elements (not shown)įILE THREE CALLED HeaderView (this is where I want whatever the user entered on WelcomeView, to be displayed) environmentObject(myUserInput) //As I try to solve this riddle via trial and error I comment/uncomment this line as needed. shadow(color: $bkgdColor.wrappedValue, radius: 5, x: 0.0, y: 0.0) autocapitalization(UITextAutocapitalizationType.words) Logo and instructional text in a VStack (not shown) Struct WelcomeView: View var myUserInput = QuizSettings() ![]() ideally, I'll be adding color and total here, but for now, just want to capture a "title" or "groupName"įILE TWO CALLED WelcomeView (this is where we capture user input via the text field) import SwiftUI How do I capture data from a TextField and essentially "store it" for display in another view?Īnd I am still getting errors and more confused than ever!įILE ONE CALLED QuizSettings.swift import FoundationĬlass QuizSettings: ObservableObject var groupName: String = "" ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |