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 Weather App with Swift (Retired) Data Modeling With Structures Initializing a Struct

William Crawford
William Crawford
4,319 Points

Stuck on Weather Init challenge

I have tried 20 different ways to do this challenge, without success: The following code compiles just fine, but fails the challenge

struct Vehicle {

var numberOfWheels: Int

var numberOfDoors: Int

var color: String

init(numberOfWheels: Int, numberOfDoors: Int, color: String) -> (Int, Int, String) {

    self.numberOfWheels = 4

    self.numberOfDoors = 4

    self.color = "Blue"

} }

Forrest Wilson
Forrest Wilson
21,862 Points

If you Copy/Paste your code into an Xcode playground, see what errors pop up and see what needs to change in your code.

2 Answers

Hello William,

Try adding the following code within the Vehicle struct. Then, fill in the values.

init () {

numberOfWheels = 
numberOfDoors = 
color = 
}
William Crawford
William Crawford
4,319 Points

Thanks, Aaron. I swear I had tried that before. Obviously not. Yours worked fine. Bill

Anytime. I'm glad to help.