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 trial
Katherine Deng
461 PointsEnum methods part 1
I'm on the part 1 of the challenge for Enum methods. I was asked to assign the enum Button's member Done to a constant named done with an associated string named "Done" It keeps telling me to assign the value to a constant done but I DID assign it to done.. here's my code: import Foundation
enum UIBarButtonStyle {
case Done
case Plain
case Bordered
}
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)
}
let done = Button.Done("Done")
Appreciate in advance for your help!
1 Answer
Steven Deutsch
21,046 PointsHey Katherine Deng,
What you need to do is access the other file for this code challenge. Click on the enums.swift tab right next to the buttons.swift tab in your code challenge. You will see they already provided you with a Button enum containing the following code:
enum Button {
case Done(String)
case Edit(String)
}
/* You then assign the Button's enum member Done to the constant done,
and give it the associated value of String */
// This is exactly how you've written it before
let done = Button.Done("Done")
Good Luck!