Search code examples
arraysmacoscocoaxcode-storyboardnscombobox

Getting selected Text Value from NSComboBox


I'm trying to get the selected string from comboBox.The string casting is not working

   let font = NSFont(name:String(combo_font.objectValueOfSelectedItem), size: 50)

How to properly get the string value?


Solution

  • NSComboBox is a subclass of NSTextField, it's simply

    NSFont(name: combo_font.stringValue, size: 50)