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 2.0 Getting Started with iOS Development Swift Recap Part 1

Stuck on this challenge.

Can anyone please tell me what's wrong in my code? Thank you!

structs.swift
struct Tag {
    let name: String
}

struct Post {

let title: String
let author: String
let tag: Tag
}

let firstPost = Post (title: String, author: String, tag: Tag) 

2 Answers

Michael Reining
Michael Reining
10,101 Points

Hi Grigory,

I noticed that you are not calling the default initializer for the Tag struct.
Also, code challenge asks you to create an instance of Post and a true instance must be initialized so I am guessing they want you to add some dummy data. Certainly seemed to do the trick.

Here is what worked for me.

struct Tag {
    let name: String
}

struct Post {

    let title: String
    let author: String
    let tag: Tag
}

let firstPost = Post(title: "Hello", author: "Author name", tag: Tag(name: "random"))

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

Thanks a lot, Michael!

I was pretty close to your solution in one of my variants, but missed one small thing... So stupid, spent a day on it...

It's funny, I downloaded your app a couple of days ago - you mentioned it in another thread here on Threehouse Community. Didn't have a chance to play with it yet. But will do, promise. We need more apps like yours and Swifty - you should know them.

Cheers, Grigory