From dd20ebda682b9c2ed301c5dc9464debc497e76f1 Mon Sep 17 00:00:00 2001 From: qinyuhang Date: Tue, 18 Oct 2016 15:36:56 +0800 Subject: [PATCH] fix crash problem --- ShadowsocksX-NG/AppDelegate.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index 60796e8..f833b61 100755 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -385,14 +385,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele showRunningModeMenuItem.state = defaults.bool(forKey: "ShowRunningModeOnStatusBar") ? 1 : 0 var serverMenuText = "Servers".localized - for v in defaults.array(forKey: "ServerProfiles")! { - let profile = v as! [String:Any] - if profile["Id"] as! String == defaults.string(forKey: "ActiveServerProfileId")! { + let mgr = ServerProfileManager.instance + for p in mgr.profiles { + if mgr.activeProfileId == p.uuid { var profileName :String - if profile["Remark"] as! String != "" { - profileName = profile["Remark"] as! String + if !p.remark.isEmpty { + profileName = p.remark } else { - profileName = profile["ServerHost"] as! String + profileName = p.serverHost } serverMenuText = "\(serverMenuText) - \(profileName)" }