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,216 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.