Getting error messages on
let answer = randomIntBetween(0, 100) - 'Missing argument label ‘high:’ in call
and
let inputAsInt = userInput.toInt() - "toInt is unavailable:Use int() initializer
One thing I have noticed in most of the tutorials on here is that you always have these supporting files and sometimes there are quite a few. Like this tutorial you just gloss over the arc4random thing which allows you to make this app and without it all the code is trash. I look at this and it does me no good. You don’t explain that supporting page at all and if you don’t understand that page you could never recreate this not even close.
That’s really helpful to know. Often times, we make assumptions when creating tutorials and sometimes forget about the target assumptions. I’ll make sure to keep your comments in mind as well as pass them off to the rest of the team.
Hi tamidkmo … Yeup, your approach would work great. In face, I would consider it the preferred approach. When we update the tutorial, I’ll make sure to incorporate your change.
One small note though. If you scroll down a little from the part “Implementing Rounds” you say: Your file should now look like this:
When you look at the script it’s already the entire end product. So I got confused that I maybe forgot some stuff.
Can you elaborate on why his approach is better? Is it simply removing verbose code? In the original code are we assigning “inputAsInt” to the value that the user inputs to the screen only to assign the optional “guess” the value of “inputAsInt”? In the “if let guess = Int(userInput)” statement you are just doing both in one statement correct? Thank you
hey Ray … i’m glad i found such an amazing tutorial…
i am on part 2 and i can’t access the helper file for method randominbetween() idk why…
if you or anyone can send to my email it fdalthaqeel@gmail.com
will be so helpful. cause i can’t continue without it.
I’m not sure what is going on … I’m able to download the file without any issues. You can download the completed project at the end of the tutorial. It’ll contain the helper file in the project.
In the “Implementing Rounds” section, the second block of code right after “Your file should now look like this:” has additions that you have not gone over yet. Such as adding var turn = 1, break, continue, turn = turn + 1
I believe that block of code should look like
import Foundation
let answer = randomIntBetween(0, high: 100)
while(true) {
print(“Enter a number between 1 and 100.”)
let userInput = input()
let inputAsInt = Int(userInput)
if let guess = inputAsInt {
if(guess > answer) {
print(“Lower!”)
} else if(guess < answer) {
print(“Higher!”)
} else {
print(“Correct! The answer was (answer).”)
}
} else {
print(“Invalid input! Please enter a number.”)
}
}
It’s not a huge deal, but I was a little confused that I was told something should look a way and it didn’t. I hope that’s helpful!