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 trialMahmoud Rajabzadeh-Mashhadi
489 PointsStructs
Not sure what I am doing right. Thanks.
struct Tag {
let firstPost = ("title", "author", "tag")
}
1 Answer
Michael Reining
10,101 PointsAs always, I recommend you use the Playground in Xcode to solve code challenges so you can see what happens and solve problems much easier on your own.
Also, the trick is to always break things down. The first part of the challenge asks you to create a new struct.
//: Playground - noun: a place where people can play
struct Tag {
let name: String
}
struct Post { // create new struct
let title: String
let author: String
let tag: Tag
}
next, use the new struct to create your first post like this
//: Playground - noun: a place where people can play
struct Tag {
let name: String
}
struct Post {
let title: String
let author: String
let tag: Tag
}
let firstPost = Post(title: "Test title", author: "author name", tag: Tag(name: "firstTag")) // be sure to also initialize the tag
I hope that helps,
Mike
PS: Thanks to the awesome resources on Team Treehouse, I launched my first app.
Now you can practice writing Swift code directly on your iPhone :-)
Code! Learn how to program with Swift
https://itunes.apple.com/app/code!-learn-how-to-program/id1032546737?mt=8