     }
 
     @IBAction func addPlaylist(_ sender: NSButton) {
-        if let selectedPlaylist = playlistArrayController.selectedObjects.first as? String {
-			let list: Array<PlayItem> = playlists[selectedPlaylist] as! Array
+        if let selectedPlaylist = playlistArrayController.selectedObjects.first as? NSDictionaryControllerKeyValuePair {
+			let list: Array<PlayItem> = selectedPlaylist.value as! Array
 			let item = PlayItem(name:"item#",link:URL.init(string: "http://")!,time:0.0,rank:list.count + 1);
             let temp = NSString(format:"%p",item) as String
             item.name += String(temp.characters.suffix(3))

        }
    }

    @IBAction func removePlaylist(_ sender: NSButton) {
        if let selectedPlayItem = playitemArrayController.selectedObjects.first as? PlayItem {
            playitemArrayController.removeObject(selectedPlayItem)
        }
        else
        if let selectedPlaylist = playlistArrayController.selectedObjects.first as? Dictionary<String,AnyObject> {
            playlistArrayController.removeObject(selectedPlaylist)
        }
    }

    @IBAction func playPlaylist(_ sender: AnyObject) {
        if let selectedPlayItem = playitemArrayController.selectedObjects.first as? PlayItem {
            let selectedPlaylist = playlistArrayController.selectedObjects.first as? String
            super.dismiss(sender)

            print("play \(selectedPlayItem.name) from \(String(describing: selectedPlaylist))")

            }
        }
            
        if let selectedPlaylist = playlistArrayController.selectedObjects.first as? NSDictionaryControllerKeyValuePair {
			if let list: Array<PlayItem> = selectedPlaylist.value as? Array<PlayItem> {
				if list.count > 0 {
					
					tableView.beginUpdates()
