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

Jack Baer
Jack Baer
5,049 Points

Swift Recap Part 1 (Build a Simple iPhone App Course)

I've been stumped on this challenge, since the error I'm getting has no explanation (It just says "Bummer," and there is nothing in the preview tab).

I also tried adding an init method to try and fix it, but nothing worked.

I would appreciate any help. Thanks!

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)"
  }
}

let firstPost = Post(title: "Book", author: "Writer", name: Tag(name: "Swift"))
let postDescription = firstPost.description

3 Answers

Jeff McDivitt
Jeff McDivitt
23,970 Points

Hi Jack -

The task's treehouse are very picky, your code will work, but look at my method you need to use tag.name

struct Tag {
    let name: String
}

struct Post {

    var title: String
    var author: String
    var tag: Tag

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

    }
}

let firstPost = Post(title: "The Task", author: "Me", tag: Tag(name: "Swift"))
let postDescription = firstPost.description()
Jack Baer
Jack Baer
5,049 Points

Thanks a bunch! Didn't realize you needed to use dot notation for the method.

Jeff McDivitt
Jeff McDivitt
23,970 Points

No problem, it is because of the way the structure is set -up that you need to use the dot notation

Didi Medina
Didi Medina
5,468 Points

I literally got stuck on this challenge for an hour bec I had a period after \(tag.name). Very picky.