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

Randell Purington
Randell Purington
9,992 Points

I haven't seen "Tag" before or at least I haven't used it yet so I am not sure how to use it

I am not sure how to use "Tag" and I don't know what it means or what it does. Could you help me with this challenge and explain what tag is? I haven't used it or not much, I don't remember.

structs.swift
struct Tag {
  let name: String
}
struct Tag {
    let name: String
}

struct Post{
    let title: String
    let author: String
    let tag: Tag
}
let firstPost = Post(title: "Bird", author: "May", tag: Tag(name: "tag"))

1 Answer

Magnus Hållberg
Magnus Hållberg
17,232 Points

Tag is a "custom" type declared in this challenge, nothing else than that. I'm guessing this challenge is about using custom types. If your problem is that you get an error its nothing else then that you have declared the struc Tag two times. As you probably know you cant use the same name for variables, constants or objects in the same scope, that will give you an error.