我知道那里有类似的问题,我看过它们,但我似乎无法解决问题。我实际上在这个项目上工作,Apple用来帮助用户学习Xcode:https://developer.apple.com/library/content/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ConnectTheUIToCode.html#//apple_ref/doc/uid/TP40015214-CH22-SW1
这是我的ViewController.swift代码:
import UIKit
class ViewController: UIViewController {
//MARK: Properties
@IBOutlet weak var nameTextField: UITextField!
@IBOutlet weak var mealNameLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a
nib.
}
//MARK: Actions
@IBAction func setDefaultLabelText(_ sender: UIButton) {
mealNameLabel.text = "Default Text"
}
}
即使我按照所有步骤操作,我仍然会收到此错误:
2017-10-14 16:18:49.195098-0400 FoodTracker[1946:46609] [MC] Lazy loading
NSBundle MobileCoreServices.framework
2017-10-14 16:18:49.195968-0400 FoodTracker[1946:46609] [MC] Loaded
MobileCoreServices.framework
2017-10-14 16:18:49.211086-0400 FoodTracker[1946:46609] [MC] System group
container for systemgroup.com.apple.configurationprofiles path is
/Users/xcodeclub/Library/Developer/CoreSimulator/Devices/54569EE9-2F14-41C6-
94D7-EDB605459B46/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-10-14 16:18:49.221000-0400 FoodTracker[1946:46609] *** Terminating app
due to uncaught exception 'NSUnknownKeyException', reason:
'[<FoodTracker.ViewController 0x7fc93bf08b80> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key setDefaultLabelText.'
有人关心帮忙吗?