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 Swift 2.0 Collections and Control Flow Control Flow With Conditional Statements The Power of Switching

randomTemperature variable error in x Code

Currently I am running xCode version 7.0.1 If anyone has encountered the error: "Cannot call value of non-function type 'UInt32' " while copying Pasan's randomTemperature variable as seen below:

import Foundation

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

The following code will eliminate the error:

import Foundation

var randomTemperature = Int(arc4random_uniform(150))

Like Pasan said, don't worry to much about the specifics of this code. Just know he will explain it in greater detail at a later time and you can continue your playground error free.

This problem might be caused by some mistake I made earlier in my code, however I figured I would post the solution in case anyone else runs into the same error.

Idris omar
Idris omar
971 Points

man you saved me a headache i was stuck at this for 3o mins straight . Thank you brother

3 Answers

Raphael Reiter
Raphael Reiter
6,820 Points

I get the same error as you. it disapears when i un indent the "case"...

I have used the syntax that Pasan used and no error occurred. Im using Xcode Version 7.1 (7B91b).

It may have just been a minor mistake on my end somewhere in the code. I know 7.1 had a few bug fixes, maybe that was one of them?

Maybe you have an error in your code, you have to be careful because XCode doesn't have a good explanation and identification of errors, most cases XCode says incorrect things. PD: Here i have to say that C#(Visual Studio) is pretty good on Error identification.

Jason Ernsdorff
Jason Ernsdorff
3,112 Points

I found if I manually type the whole line exactly as it is supposed to be that it works but if I use the autocompletion to fill in the line in XCode that it generates errors and has different formatting. Just type it as Pasan has it manually and it should work.