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

Steven Beckham
Steven Beckham
2,010 Points

The Power of Switching errors

import Foundation 
var randomTemperature = Int 
(arc4random_uniform(UInt32(150)))

Using this code in Xcode I get two errors. First is on line 2: "expected member name or constructor call after type name". This goes away if I add brackets after Int.

var randomTemperature = Int()

The remaining caution says "Editor placeholder in source file". I know some things are changing with the update to Swift 3.0 but I don't know how to fix this one and Xcode won't generate a number.

1 Answer

Can you link to the course you are working on. I'm unsure about the second one but if you are trying to set randomTemperature to type Int you can do that as below.

var randomTemperature: Int

Steven Beckham
Steven Beckham
2,010 Points

It's at the 4:00 mark of: https://teamtreehouse.com/library/swift-20-collections-and-control-flow/control-flow-with-conditional-statements/the-power-of-switching

Switching this code, as shown in the video above:

var randomTemperature = Int

for this:

var randomTemperature: Int

does fix part of the problem. The other part of the problem seems to be something in Xcode. It highlighted "UInt32" in grey and when I double clicked on it the highlight went away and the code suddenly started working.