Cocoa Programming for OS X func voiceNameForIdentifier not running

I´m having a hard time running the tutorial code… I am stuck with the function, as it seems that the attributes method is written differently. Any help with this issue will be greatly appreciated!!!

Here is the code in my environment:

“““
func voiceNameForIdentifier(identifier: String) -> String? {
if var attributes = NSSpeechSynthesizer.attributes(forVoice: identifier) {
return attributes[NSVoiceName] as? String
}
else {
return nil
}
}

“““

Thanks!!!