UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Progress - Green-Orion: Just finished Day 43 & question on Previews

Forums > 100 Days of SwiftUI

Just wanted to share! Posted this initially to share I'd finished Day 41, and edited based on feedback.

1      

Excellent!

There are a number of folks here willing to help explain concepts or help you when you're stuck!

Please Read

Please read this thread and the response from @twoStraws. See-> How to Post Progress

In short, please keep posting your progress. However, instead of a new post for each day, you can edit this post!

Instead of the title "Just Finished Day 41", consider changing your post title to: Green-Onion's Progress: Day 41 Complete! Next week it will read: Green-Onion's Progress: Day 47 Complete! Keep changing the title as you progress.

Add to the post! After each milestone, post a snip of your progress, your quiz scores, and the concepts you found fun, or difficult. There are other articles, blog posts, or YouTube videos we can point you to, to help you solidify a concept, or to push your boundaries.

Keep coding!

2      

For inspiration, here is Vince's journey starting at Day 69. This is a great model to follow.

See-> Vince's 100 Day Journey

1      

Thanks for the feedback. Now up to Day 43. I needed some help to finish Day 42 Challenges - my main issue was to get the Previews working for the layout Views - I have a hard time figuring out what needs to be included to make the Previews work. I've gone through the course material several times but it still is a bit of a guessing game to me. If there is another guide on how to make Previews work for views that take in information from parent or sibling views, would anybody be able to share that with me? Many thanks.

1      

Sander trips on a common problem!

I have a hard time figuring out what needs to be included to make the Previews work.

Not sure what challenge you have with previews, but here are two writeups from other posts.

See-> Preview Scaffolding

And here's another post describing setting up variables to work with previews. See-> More on Previews

KEEP CODING!

2      

Paul recommend that you make a static property of example in your data struct eg

struct User: Identifiable {
    var id = UUID()
    var firstName: String
    var lastName: String

    static let example = [
        User(firstName: "Paul", lastName: "Hudson"),
        User(firstName: "Nigel", lastName: "Gee")
    ]
}

then when you want to use it you can simple do

struct ContentView: View {
    let users: [User]
    var body: some View {
        List(users) { user in
            Text("\(user.firstName) \(user.lastName)")
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView(users: User.example) // <- Using static example
    }
}

1      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.