NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

Hacking with watchOS Project 8 Code improvement

Forums > Books

I think it makes more sense to make "title" a computed property to make the UI more reactive and bug-prone, since its value is derived from correctValues:

var title: String {
    if correctValues.isEmpty {
        return "Safe Crack"
    } else {
        return correctValues.joined(separator: ", ")
    }
}

   

Hacking with Swift is sponsored by Fernando Olivares

SPONSORED Ever ask for help and your reviewer immediately notices issues you missed? Fernando Olivares is a 10-year veteran from Big Nerd Ranch and Lambda School who can help hone your app building skills, and he's just launched a new book that does just that – use the code "hacking" to save $5!

Buy the book

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

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

Not logged in

Log in
 

Link copied to your pasteboard.