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 Cleaning Up Our Date

Trying to understand what Pasan did at 6:15?

I don't understand what Pasan did when he wrote.

return dateFormatter.stringFromDate(weatherDate)

and why did he change this line from Int to String

var currentTime: String

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Frank,

The stringFromDate method accepts a NSDate instance in which returns as a String using the format we specified just above our return statement, because we have access an a UNIX date we pass the value of it to our dateStringFromUnixtime method which gives us a human readable date string instead of numbers which don't make much sense.

Changing currentTime to be a String is required since as I said above stringFromDate returns a string therefore the type Int is a mismatch and would trigger a compiler error.

Hope that helps.

Thanks Chris that makes since! Cheers!