Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift 2.0 Enumerations and Optionals Introduction to Enumerations Enum Methods

Brian Uribe
Brian Uribe
3,488 Points

Where to start?

I'm not sure where to start with this. I took a shot and i'm falling flat

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

let done = enum Done: String {

enum Button {
    case Done(String)
    case Edit(String)

1 Answer

J.D. Sandifer
J.D. Sandifer
18,813 Points

One place to start if you're having trouble is re-reading the directions. Sometimes there's a ton of information packed in there and it's easy to miss key points. I often find myself re-reading them a couple times before I start on some problems.

Take a look at this problem's first line of directions again:

"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."

After you figure out what needs to change there, here's the way you want to assign the Enum to the constant:

let constant = Enum.Type

(that's not the actual code, you'll need to fill in the correct names for constant, Enum, and Type to fit this problem)