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 trialDavid Oliveira
iOS Development with Swift Techdegree Student 4,549 PointsUnsure about the changes made to Swift 4 and this project, or if I'm just wrong.
in the BarButton enum function you have told us to label button() that returns a UIBarButtonItem object, the style: parameter says to use UIBarButtonStyle.done and UIBarButtonStyle.plain as the arguments to initialize the Enum. This web compiler is saying this member property doesn't exist.
When going to the playground, in fact there is no UIBarButtonStyle that shows up in the autocomplete, but there is a UIBarButtonItemStyle which have both .done and .plain members.
The last thing about this test - in the directions it says to assign a constant named button and call the function we just wrote. But when it fails, it says "Make sure you assign the constant to doneButton". I've tried both ways, and I've tried to define a constant for done and button, and doneButton - But it still fails.
I am puzzled and not sure if this is a swift 3 vs swift 4 error. I know some functions and items have been deprecated.
Thanks for your insight.
-Dave
// Example of UIBarButtonItem instance
// let someButton = UIBarButtonItem(title: "A Title", style: .plain, target: nil, action: nil)
enum BarButton {
case done(title: String)
case edit(title: String)
func button() -> UIBarButtonItem {
switch self {
case .done(let title): return UIBarButtonItem(title: title, style: BarButtonItemStyle.done, target: nil, action: nil)
case .edit(let title): return UIBarButtonItem(title: title, style: BarButtonItemStyle.plain, target: nil, action: nil)
}
}
}
let done = BarButton.done(title: "Save").button()
//let button = BarButton.done(title: "Save").button()
David Oliveira
iOS Development with Swift Techdegree Student 4,549 PointsDavid Oliveira
iOS Development with Swift Techdegree Student 4,549 PointsActually I just figured it out looking at the other questions that were already asked.
Thanks a ton!
-Dave