Post

Replies

Boosts

Views

Activity

Reply to Preview Autogenerated Code Error
Thank you for your reply. Here's what my preview looks like. It's right above the expansion of the #Preview macro. I just added the return keyword right before HistoryView(words: $randomWords), but the problem persists. #Preview { let randomWord1 = FetchWord.getRandomWord() let randomWord2 = FetchWord.getRandomWord() @State var randomWords = [Word(word: randomWord1.0, IPA: randomWord1.1, lineNumber: randomWord1.2), Word(word: randomWord2.0, IPA: randomWord2.1, lineNumber: randomWord2.2)] return HistoryView(words: $randomWords) } What do you mean by "@State inline"? Does that mean I can't declare a ``@State` variable in my preview? Sorry, I am new to app development.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’24
Reply to File Access
It's a text file which I only need to read.
Replies
Boosts
Views
Activity
Jan ’24
Reply to Preview Autogenerated Code Error
Thank you for your reply. Here's what my preview looks like. It's right above the expansion of the #Preview macro. I just added the return keyword right before HistoryView(words: $randomWords), but the problem persists. #Preview { let randomWord1 = FetchWord.getRandomWord() let randomWord2 = FetchWord.getRandomWord() @State var randomWords = [Word(word: randomWord1.0, IPA: randomWord1.1, lineNumber: randomWord1.2), Word(word: randomWord2.0, IPA: randomWord2.1, lineNumber: randomWord2.2)] return HistoryView(words: $randomWords) } What do you mean by "@State inline"? Does that mean I can't declare a ``@State` variable in my preview? Sorry, I am new to app development.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’24
Reply to View Update Failure
I figured it out by myself. Thank you for trying to help though!
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’24