Task: “Add a button that will remove all the user’s defaults. Label the button Reset Preferences. Do not forget to update the window to reflect the new defaults.”
Retrieve your Bundle Identifier from your Target > SpeakLine > General > Bundle Identifier
class PreferenceManager {
...
func resetDefaultPreferences() {
userDefaults.removePersistentDomainForName("com.bignerdranch.SpeakLine")
registerDefaultPreferences()
}
let defaultVoice = preferenceManager.activeVoice!
if let defaultRow = voices.indexOf(defaultVoice)
{
let indices = NSIndexSet(index: defaultRow)
tableView.selectRowIndexes(indices, byExtendingSelection: false)
tableView.scrollRowToVisible(defaultRow)
print("defaultRow = \(defaultRow)")
}
}[/code]