lundi 29 juin 2015

ViewController does not have a member named tipCalc

//
//  ViewController.swift
//  TipCalculator
//
//  Created by Mathias Bakken on 6/28/15.
//  Copyright (c) 2015 Mathias Bakken. All rights reserved.
//

I have 6-8 instances where I am receiving the error for not having the member tipCalc. I attempted to make an empty variable, but that only made things worse.

import UIKit

class ViewController: UIViewController {
@IBOutlet var totalTextField : UITextField!
@IBOutlet var servQualitySlider : UISlider!
@IBOutlet var foodQualitySlider : UISlider!
@IBOutlet var servQualityLabel : UILabel!
@IBOutlet var foodQualityLabel : UILabel!
@IBOutlet var resultsTextView : UITextView!
@IBAction func calculateTapped(sender : AnyObject){
    tipCalc.total = Double((totalTextField.text as NSString).doubleValue)
    let possibleTips = tipCalc.returnPossibleTips()
    var results = ""
    for (tipPct, tipValue) in possibleTips{
        results += "\(tipPct)%: \(tipValue)\n"
    }
resultsTextView.text = results
}
@IBAction func servQualityChanged(sender : AnyObject){
    tipCalc.servQuality = Double(servQualitySlider.value)/100.0
    refreshUI()
}
@IBAction func foodQualityChanged(sender : AnyObject){
    tipCalc.foodQuality = Double(foodQualitySlider.value)/100.0
    refreshUI()
}
@IBAction func viewTapped(sender : AnyObject){
    totalTextField.resignFirstResponder()
}
let tipCalc = TipCalculatorModel(total: 33.25, foodQuality: 0.06, servQuality: 0.06)

func refreshUI(){
    totalTextField.text = String(format: "%0.2f", tipCalc.total)
    foodQualitySlider.value = Float(tipCalc.foodQuality) * 100.0
    servQualitySlider.value = Float(tipCalc.servQuality) * 100.0
    foodQualityLabel.text = "Food Quality 1-10 (\(Int(foodQualitySlider.value))%)"
    servQualityLabel.text = "Service Quality 1-10 (\(Int(servQualitySlider.value))%)"
    resultsTextView.text = ""
}

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    refreshUI()
}


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

} I am getting a bunch of the same error messages saying "ViewController does not have a member named tipCalc"

I am also receiving the error "Use of unresolved identifier TipCalculatorModel"

How do I fix this issue? Thank you!

Aucun commentaire:

Enregistrer un commentaire