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 trialChance Robertson
2,975 PointsIn the editor you've been provided with two files buttons.swift that contains some source code for you to use and enums.
In the editor you've been provided with two files buttons.swift that contains some source code for you to use and enums.swift where you will be writing code.
Let's start simple. To a constant named done assign an enum value of type Button with the member Done. This member takes an associated value; assign it the string "Done".
I'm a failure and need help :'(
Please post the full code solution.
import Foundation
enum UIBarButtonStyle {
case Done
case Plain
case Bordered
let done = Button.Done("Done")
}
class UIBarButtonItem {
var title: String?
let style: UIBarButtonStyle
var target: AnyObject?
var action: Selector
init(title: String?, style: UIBarButtonStyle, target: AnyObject?, action: Selector) {
self.title = title
self.style = style
self.target = target
self.action = action
}
}
enum Button {
case Done(String)
case Edit(String)
}
1 Answer
John Roque Jorillo
13,117 PointsIn the instruction it was mentioned that we will be writing code in enums.swift.
enums.swift where you will be writing code.
enum Button { case Done(String) case Edit(String) }
let done = Button.Done("Done")
i'm also having trouble reading cause im lazy, but we need to :'(