Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBob Walters
1,969 PointsEnum issue & don't understand error msgs
The error msgs they keep telling me to assign different things.
E.g., they have suggested that I assign to a constant named "done", "doneButton", and "button". It's a moving target as I comply with the previous one! :(
// Example of UIBarButtonItem instance
// let someButton = UIBarButtonItem(title: "A Title", style: .plain, target: nil, action: nil)
enum BarButton {
case done(title: String)
case edit(title: String)
func button() -> UIBarButtonItem {
switch self {
case .done(let thisTitle):
return UIBarButtonItem(title: thisTitle, style: .done, target: nil, action: nil)
case .edit(let thisTitle):
return UIBarButtonItem(title: thisTitle, style: .plain, target: nil, action: nil)
}
}
}
let button = BarButton.done(title: "Save").button()
1 Answer
Dhanish Gajjar
20,185 PointsIn the first task you create an instance of Barbutton type .done and assign it to a constant done.
In the second, you simply call the method button() on the constant created earlier, and assign it to a new constant called button.
Hope it helps !
let done = BarButton.done(title: "Save")
let button = done.button()
Bob Walters
1,969 PointsBob Walters
1,969 Pointsthnx!