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!

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

iOS Swift 2.0 Protocols Swift 2.0 Protocols Protocols With Methods

Welby Obeng
Welby Obeng
20,340 Points

Error: The ColorSwitchable protocol needs to have a method requirement as specified in the directions.

In the editor below, I've declared a class, WifiLamp, that represents an interface to one of those Internet of Things lamps. The class models state that determines whether the lamp is on or off and a color, represented by the Color enum. For the first step, declare a protocol named ColorSwitchable. The protocol has a single requirement: a method named switchColor that takes a value of Color as an argument. For the sake of this challenge, make sure your method parameter is named color.

Am I doing anything wrong here?

// Declare protocol here

protocol ColorSwitchable {
    func switchColor(color:Color)

enum LightState {
    case On, Off

enum Color {
    case RGB(Double, Double, Double, Double)
    case HSB(Double, Double, Double, Double)

class WifiLamp {
    let state: LightState
    var color: Color

    init() {
        self.state = .On
        self.color = .RGB(0,0,0,0)

1 Answer

Welby Obeng
Welby Obeng
20,340 Points

it was a spacing issue, func switchColor(color:Color) should be func switchColor(color: Color)