After upgrading to Swift 3, I started getting a BAD INSTRUCTION
error every time I clicked a button that was supposed to open a new view controller, relating to the code that's in my ViewDidLoad. Here's the code in my 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
I'm basically using NSUserDefaults to populate the Preferences area correctly. It was working fine in Swift 2/Xcode 7, but after updating to Swift 3/Xcode 8 it gives me trouble. Any thoughts or ideas would be appreciated!