Hello,
I am a newbie trying to learn swift code. I found an exercise on youtube which consists of a button that counts as you click on the button. I am trying to replicate it and I am getting a couple of errors. I added the code below and also the errors in Italic. I also included a screenshot and the link of the video I was trying to replicate the code from.
If you could help me I would be very grateful.
cheers
Josh
//
// ViewController.swift
// GTGdraft3
//
// Created by Josh on 18/05/2020.
// Copyright © 2020 Josh. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet var ScoreLbl: UILabel!
@IBOutlet var HighscoreLbl: UILabel!
@IBOutlet var Reset: UIButton!
@IBOutlet var Counter: UIButton!
var Score = 0
var Highscore = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func ResetAction(_ sender: AnyObject) {
}
@IBAction func Counteraction(_ sender: AnyObject) {
Score ++ *//This is the error Use of unresolved operator '++'; did you mean '+= 1'?*
ScoreLbl.text = NSString(format: "Score : %i", Score)
if (Score > Highscore){
Highscore = Score
HighscoreLbl.text = NSString(format: "highscore : %i",Highscore) // this is the other error *Cannot assign value of type 'NSString' to type 'String'*
}
}
}