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 Build a Simple iPhone App with Swift Getting Started with iOS Development Swift Recap Part 1

Jason Ernsdorff
Jason Ernsdorff
3,112 Points

Code works in Xcode with desired results but not in Team Tree House code editor.

I double checked the instructions. I don't know if this has to do with different versions of XCode. I have the latest Xcode and the desired results appear when I put this into a playground but the code editor in TeamTreeHouse won't accept my code.

Does anyone know what the problem is or should I contact support?

structs.swift
struct Tag {
    let name: String
}

struct Post{
    let title: String
    let author: String
    let tag: Tag

    func description() -> String{
        return "\(title) by \(author).  Filed under \(tag.name)"
    }
}

let firstPost = Post(title: "iOSDevelopment", author: "Apple", tag: Tag(name: "swift"))
let postDescription = firstPost.description()

2 Answers

andren
andren
28,558 Points

The code checker for challenges like this is often very picky about the string you return/print. It has to match the expected string to the letter, including the exact same spacing.

The issue with your code is that you have two spaces in a row in the middle of the string, if you remove one of those extra spaces like this:

struct Tag {
    let name: String
}

struct Post{
    let title: String
    let author: String
    let tag: Tag

    func description() -> String{
        return "\(title) by \(author). Filed under \(tag.name)"
    }
}

let firstPost = Post(title: "iOSDevelopment", author: "Apple", tag: Tag(name: "swift"))
let postDescription = firstPost.description()

Then your code will be accepted.

Jason Ernsdorff
Jason Ernsdorff
3,112 Points

Thanks so much. I knew it had to be something easily overlooked. Really appreciate it. If it happens again I’ll make sure to look for extra white space. Jeesh.