0

EDIT

//  EnterValueScreen.swift
//  myfirstapp

import UIKit

class EnterValueScreen: UIViewController {

    override func viewDidLoad() {
        // Do any additional setup after loading the view.
    }

        // outlet fields


    @IBOutlet weak var enterValue: UITextField!
    var val: Double!
    var convertedVal: Double!
    var weightBool: Bool = true
    var weightName: String!

    @IBOutlet weak var outputLabel: UILabel!
    @IBOutlet weak var segmentControl: UISegmentedControl!
    //outputField.text = ans

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        enterValue.resignFirstResponder()
    }

    @IBAction func enterValueTouch(_ sender: UITextField) {
    }


    @IBAction func indexedWeight(_ sender: Any) {
        switch segmentControl.selectedSegmentIndex {
        case 0:
            weightBool = true
        case 1:
            weightBool = false
        default:
            weightBool = true
        }
    }
    //
    func convertEquations(_ weight: Bool, insertValueFromTextField value: Double) -> Double {

        if weight == true {
            print("we doin Kgs")
            convertedVal = 2.20462 * value
            weightName = "Pounds"


        } else {
            print("we doin lbs")
            convertedVal = value / 2.20462
            weightName = "Kilos"
        }

        return convertedVal.rounded(toPlaced: 1)
    }

    @IBAction func convertButton(_ sender: UIButton) {
        //execute function converter

        val = Double(enterValue.text ?? "0")

        convertEquations(weightBool, insertValueFromTextField: val)

        outputLabel.text = String(convertedVal) + " \(weightName!)"
    }
}


extension Double {
    func rounded(toPlaced places:Int) -> Double {
        let divisor = pow(10.0, Double(places))
        return (self * divisor).rounded() / divisor
    }
}

This is the error I get given:

2019-05-06 11:45:01.601637+0100 myfirstapp[3695:385041] Failed to set () user defined inspected property on (myfirstapp.EnterValueScreen): [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key . 2019-05-06 11:45:04.016105+0100 myfirstapp[3695:385041] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/james/Library/Developer/CoreSimulator/Devices/976DE92D-F68B-4608-9EC5-E68B0EB658A6/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 2019-05-06 11:45:04.016549+0100 myfirstapp[3695:385041] [MC] Reading from private effective user settings. 2019-05-06 11:45:04.071007+0100 myfirstapp[3695:385041] Can't find keyplane that supports type 4 for keyboard iPhone-PortraitTruffle-NumberPad; using 20615_PortraitTruffle_iPhone-Simple-Pad_Default

1
  • Please repost the error. Copy and paste it exactly. There should not be all of those // and you left off the most important part of the error.
    – rmaddy
    May 4, 2019 at 15:39

1 Answer 1

0

Try to use super.viewDidLoad(); in your override func viewDidLoad() method.

like

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}

If it did not work then try to delete and reconnect connection of viewController from storyboard.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.