![](/img/trans.png)
[英]Failed to set (key_name) user defined inspected property . this class is not key value coding-compliant for the key
[英]Xcode error: Failed to set () user defined inspected property: this class is not key value coding-compliant for the key
編輯
// 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
}
}
這是我得到的錯誤:
2019-05-06 11:45:01.601637 + 0100 myfirstapp [3695:385041]無法在(myfirstapp.EnterValueScreen)上設置()用戶定義的檢查屬性:[setValue:forUndefinedKey:]:此類不符合鍵值編碼為了鑰匙。 2019-05-06 11:45:04.016105 + 0100 myfirstapp [3695:385041] [MC] systemgroup.com.apple.configurationprofiles路徑的系統組容器是/ 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]從私人有效用戶設置讀取。 2019-05-06 11:45:04.071007 + 0100 myfirstapp [3695:385041]無法找到支持鍵盤iPhone-PortraitTruffle-NumberPad類型4的鍵盤; 使用20615_PortraitTruffle_iPhone-Simple-Pad_Default
嘗試使用super.viewDidLoad();
在您的override func viewDidLoad()
方法中。
喜歡
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
如果它不起作用,那么嘗試從storyboard中刪除並重新連接viewController的連接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.