升级到Swift 3之后,每次点击一个应该打开一个新视图控制器的按钮时,我都会收到BAD INSTRUCTION
错误,该按钮与我的ViewDidLoad中的代码有关。这是我的ViewDidLoad中的代码:
if teacherModeVar == "Teacher" && password != "No password set" {
teacherModeRadioButton.state = NSOnState
singleUserRadioButton.state = NSOffState
unlockSettingsLabel.isEnabled = true
unlockSettingsTextBox.isEnabled = true
unlockSettingsButton.isEnabled = true
levelChoiceLabel.isEnabled = false
levelChoiceHelp.isEnabled = false
levelChoiceOption.isEnabled = false
teacherPasswordLabel.isEnabled = false
teacherPasswordHelp.isEnabled = false
enterNewPasswordLabel.isEnabled = false
enterNewPasswordBox.isEnabled = false
confirmPasswordLabel.isEnabled = false
confirmPasswordBox.isEnabled = false
saveNewPasswordButton.isEnabled = false
typeOfLearnerLabel.isEnabled = false
typeOfLearnerOption.isEnabled = false
} else {
teacherModeRadioButton.state = NSOnState
singleUserRadioButton.state = NSOffState
unlockSettingsLabel.isEnabled = false
unlockSettingsTextBox.isEnabled = false
unlockSettingsButton.isEnabled = false
levelChoiceLabel.isEnabled = true
levelChoiceHelp.isEnabled = true
levelChoiceOption.isEnabled = true
teacherPasswordLabel.isEnabled = true
teacherPasswordHelp.isEnabled = true
enterNewPasswordLabel.isEnabled = true
enterNewPasswordBox.isEnabled = true
confirmPasswordLabel.isEnabled = true
confirmPasswordBox.isEnabled = true
saveNewPasswordButton.isEnabled = true
typeOfLearnerLabel.isEnabled = false
typeOfLearnerOption.isEnabled = false
}
if teacherModeVar == "Single" {
singleUserRadioButton.state = NSOnState
teacherModeRadioButton.state = NSOffState
unlockSettingsLabel.isEnabled = false
unlockSettingsTextBox.isEnabled = false
unlockSettingsButton.isEnabled = false
levelChoiceLabel.isEnabled = false
levelChoiceHelp.isEnabled = false
levelChoiceOption.isEnabled = false
teacherPasswordLabel.isEnabled = false
teacherPasswordHelp.isEnabled = false
enterNewPasswordLabel.isEnabled = false
enterNewPasswordBox.isEnabled = false
confirmPasswordLabel.isEnabled = false
confirmPasswordBox.isEnabled = false
saveNewPasswordButton.isEnabled = false
typeOfLearnerLabel.isEnabled = true
typeOfLearnerOption.isEnabled = true
我基本上使用NSUserDefaults正确填充“首选项”区域。它在Swift 2 / Xcode 7中运行良好,但在更新到Swift 3 / Xcode 8后,它给我带来了麻烦。任何想法或想法将不胜感激!