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 trialUnsubscribed User
Courses Plus Student 2,233 Pointshelp me
How to get rid of arcs definition (df) " iOS Development Apple Tag(name: "Filed under swift") "
struct Tag {
let name: String
}
struct Post {
let title: String
let author: String
let tag: Tag
func description() -> (String) {
return ("\(title) \(author) \(tag)")
}
}
let df = Tag(name: "Filed under swift")
let firstPost = Post(title: "iOS Development", author: "Apple", tag: df)
let postDescription = firstPost.description()
2 Answers
Thomas Dobson
7,511 PointsMohammad,
You sort of had the write idea. See my notes in your code:
struct Tag {
let name: String
}
struct Post {
let title: String
let author: String
let tag: Tag
func description() -> (String) {
return ("\(title) \(author) \(tag)") // add misc text in-between your interpolations to get the desired output of the challenge.
}
}
let df = Tag(name: "Filed under swift") //Add the unnecessary text to the string portion of your description method. Then call the tag as part of firstPost.
let firstPost = Post(title: "iOS Development", author: "Apple", tag: df)
let postDescription = firstPost.description()
Here is how I did 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)" //pull the name property from tag
}
}
let firstPost = Post(title: "iOS Development", author: "Apple", tag: Tag(name: "Swift")) // call Post
let postDescription = firstPost.description() // call description method.
I hope this helps.
Unsubscribed User
Courses Plus Student 2,233 Pointsthanks, it's Done