New to Swift -Help with errors!

I am trying to learn Swift, by following the Stanford University CS193-P course.  Was OK until I got to lecture 5.

Getting multiple errors, even though I have checked the code against the Demo Code.

Here is the file where the errors occured, with errors noted after the file.

Is it to do with the way the files are linked, as this was not to clear in the lecture?


/
/
/
/
/
/
import UIKit
class ViewController: UIViewController
{
  var expression = FacialExpression(eyes: .closed, mouth: .frown) {               //eyes is indicated with triangle under e
  didSet {
  updateUI()
  }
  }

  private func updateUI()
  {
  switch expression.eyes {
  case .open:
  FaceView?.eyesOpen = true
  case .closed:
  FaceView?.eyesOpen = false
  case .squinting:
  FaceView?.eyesOpen = false
  }
  FaceView?.mouthCurvature = mouthCurvatures[expression.mouth] ?? 0.0
  }
  private let mouthCurvatures =
  [FacialExpression.Mouth.grin:0.5,.frown:-1.0,.smile:1.0,.neutral:0.0,.smirk:-0.5]
  @IBOutlet weak var FaceView: FaceView! {
  didSet {
  let handler = #selector(FaceView.changeScale(byReactingTo:))
  let pinchRecognizer = UIPinchGestureRecognizer(target: FaceView, action: handler)
  FaceView.addGestureRecognizer(pinchRecognizer)
  let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(toggleEyes(byReactingTo:)))
  tapRecognizer.numberOfTapsRequired = 1
  FaceView.addGestureRecognizer(tapRecognizer)
  let swipeUpRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(increaseHappiness))
  swipeUpRecognizer.direction = .up
  FaceView.addGestureRecognizer(swipeUpRecognizer)
  let swipeDownRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(decreaseHappiness))
  swipeDownRecognizer.direction = .down
  FaceView.addGestureRecognizer(swipeDownRecognizer)
  updateUI()
  }
  }
  func increaseHappiness()
{
  expression = expression.happier
  }
  func decreaseHappiness(){
  expression = expression.sadder
  }
  func toggleEyes(byReactingTo taprecognizer: UITapGestureRecognizer){

  if taprecognizer.state == .ended {
  let eyes: FacialExpression.Eyes = (expression.eyes == .closed) ? .open : .closed
  expression = FacialExpression(eyes: eyes, mouth: expression.mouth)

  }
  }
}




Errors

Line 11 – argument passed to call that takes no arguments

 

 

Demo code can be seen on Google Drive owner: Digit77.com

Powered by WPeMatico

About

You may also like...

Comments are closed.