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

I try to make a guessing game to guess 1~100 but here is few troubles ,......

import UIKit

class ViewController: UIViewController {

var answer = Int(arc4random_uniform(100)+1)
var maxnumber = 100
var mininumber = 1

@IBOutlet weak var messagelabel: UILabel!

@IBOutlet weak var inputtextfield: UITextField!

@IBAction func makeaguess(_ sender: UIButton) {

    let inputNumber = Int (inputtextfield.text!)
    if  inputNumber > maxnumber{
        messagelabel.text = "too large!guess a number between \(mininumber)~\(maxnumber)"
    }
    else if inputNumber <mininumber{
        messagelabel.text = "too small! guess a number between \(mininumber)~\(maxnumber)"
    }

override func viewDidLoad() {
    super.viewDidLoad()
    print(answer)
    inputtextfield .becomeFirstResponder()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

I dont understand why it can't work..... can I post the picture on it? cause I think It might be clear to know....?? but how to upload it ?

Jeff McDivitt
Jeff McDivitt
23,970 Points

It would be easiest to upload your project on GitHub that way we can download the full project and assist you