iOS Build a Simple iPhone App with Swift Getting Started with iOS Development Swift Recap Part 1

Bartosz Kulasiewicz
Bartosz Kulasiewicz
1,130 Points

What wrong with this? incorrect output :v

Help me pls

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: "IOSDevelopment", author: "Apple", tag: Tag.init(name: "Swift"))
let postDescription = firstPost.description()

1 Answer

In your description method, try writing “tag.name” instead of “tag”. This way you’re retrieving the name constant from the tag instance.