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 trialMehran Moradi
11,140 PointsI am stuck and it says make sure you assign to a constant name doneButton
I am stuck and it says make sure you assign to a constant name doneButton
import UIKit
enum BarButton {
case done(String)
case edit(String)
func button() -> UIBarButtonItem {
switch self {
case .done(let value):
return UIBarButtonItem(
title: value,
style: .done,
target: nil,
action: nil)
case .edit(let value):
return UIBarButtonItem(
title: value,
style: .plain,
target: nil,
action: nil)
}
}
}
let done = BarButton.done("Save")
let doneButton = done.button()
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! You're fairly close here so, I'm going to give a few hints.
- The
import UIKit
is unnecessary and produces a compiler error for me - The
case done
andcase edit
which take aString
should have an external label oftitle
- The external label of
title
should be used when sending in your "Save" string - Although the Bummer! message references a constant named
doneButton
, the instructions say that the constant should be namedbutton
. RenamedoneButton
to simplybutton
I think you can get it with these hints, but please let me know if you're still stuck!
Mehran Moradi
11,140 PointsThanks Again Jennifer. Jennifer If want to ask questions can I ask directly from you? Can you please share with me your email? I want in some cases if possible ask some learning questions