|
I am trying to complete the day 60 challenge on the 100 days of SwiftUI course but have ran into a problem. XCode is not showing any errors in my code but the simulator and preview aren't displaying the list that i inputed - just a white screen with a navigation title. I have spent hours trying to figure out this problem, watching numerous videos from earlier in the course and looking at other solutions people have used but still cannot figure out what is going wrong. Does anyone have any solutions, tips or links to useful videos for this problem? And, it would be much appreciated if somebody could try my code on their mac to see if its just my XCode playing up. Here is my code: ContentView.swift
User.swift
Friend.swift
|
|
@oscar is trying to track down a bug.....
Welcome to Hacking with SwiftUIYou are making mistakes? Good job! That is part of the learning process. Help yourself now by learning some debugging techniques. One of the most basic techniques is to sprinkle your code with print statements. Later, you should look into assert() statements! See -> Assert Yourself But start with print(). Comment your code!Next, it's useful if we know that you understand what you're writing. So take a moment to add comments documenting your understanding. If you're not grokking a concept, we can steer you in the right direction. Your codeI copied your code, added several print statements and found your error in 5 minutes. HINT: It's a scope issue. Something in or out of scope. Add a warning light to your NavigationStack! This is one of those annoying lights on your car's dashboard. Just put it there whilst you debug your code. What is the output? Is the number what you expected?
Depending on the value in your Warning Light, you may want to look deeper into your code.
Keep Coding |
SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.