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

iOS Intermediate Swift 2 Extensions and Protocols Protocol Conformance Through Extensions

Grant Thomas
Grant Thomas
13,705 Points

Why doesn't Treehouse accept this answer?

When I plug this into Xcode it seems to work perfectly, but when I plug it back into Treehouse I get this error:

swift_lint.swift:16:21: error: value of type 'String' has no member 'capitalizedString'
        return self.name.capitalizedString
protocols.swift
protocol PrettyPrintable {
    var prettyDescription: String { get }
}

struct User {
    let name: String
    let ID: Int
}

// Enter your code below

extension User: PrettyPrintable {
    var prettyDescription: String {
        return self.name.capitalizedString
    }
}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Grant,

You've pretty much got it, except the challenge wants you return a formatted string (I'm not sure where you were going with this return statement). All you need a is simple formatted string (I used interpolation for this example) that returns the information for the User instance.

Below is the corrected code for your reference. Hope it makes sense.

extension User: PrettyPrintable {
    var prettyDescription: String {
        return "/(name) + /(ID)"
    }
}

Keep Coding! :) :dizzy:

Grant Thomas
Grant Thomas
13,705 Points

That makes sense. Thanks for you help.