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

Reza Shirazian
Reza Shirazian
5,337 Points

code works fine, editor says it could not be compiled but provides no output

code works fine, editor says it could not be compiled but provides no output

structs.swift
struct Tag {
    let name: String
}

struct Post {
  let title: String
  let author: String
  let tag: Tag
}

let firstPost: Post

2 Answers

Michael Drexler
Michael Drexler
4,374 Points

Hy Reza Shirazian,

you are declaring a constant with the name "firstPost" but you donΒ΄t assign a value to this constant. Have you already tried to assign a value/instance to this constant?

Reza Shirazian
Reza Shirazian
5,337 Points

Yea I figured it out. The instructions didn't say we should assign values to it.

Michael Drexler
Michael Drexler
4,374 Points

The instructions say the following: "Create an instance of Post and assign it to a constant named firstPost."

That means you have to create an object of the type Post and assign it to the constant. Because a struct provides a default initializer method you can just simple create an object like the following code shows.

let firstPost: Post = Post(title: "AnyTitle", author: "AnyAuthor", tag: Tag(name: "AnyName"))