From 5366345b7998812b8b9e5501104954c8ab605542 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E5=AE=87=E8=88=AA?= Date: Sat, 22 Jul 2017 12:11:12 +0800 Subject: [PATCH] Move profile manager function to the Class the function should be in the Class instead of the AppDelegate --- ShadowsocksX-NG/AppDelegate.swift | 7 ------- ShadowsocksX-NG/ServerProfileManager.swift | 9 ++++++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ShadowsocksX-NG/AppDelegate.swift b/ShadowsocksX-NG/AppDelegate.swift index 69300c1..9c994d3 100644 --- a/ShadowsocksX-NG/AppDelegate.swift +++ b/ShadowsocksX-NG/AppDelegate.swift @@ -230,13 +230,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele } func applyConfig() { - let profileMgr = ServerProfileManager.instance - if profileMgr.profiles.count == 0{ - let notice = NSUserNotification() - notice.title = "还没有服务器设定!" - notice.subtitle = "去设置里面填一下吧,填完记得选择呦~" - NSUserNotificationCenter.default.deliver(notice) - } let defaults = UserDefaults.standard let isOn = defaults.bool(forKey: "ShadowsocksOn") let mode = defaults.string(forKey: "ShadowsocksRunningMode") diff --git a/ShadowsocksX-NG/ServerProfileManager.swift b/ShadowsocksX-NG/ServerProfileManager.swift index 7dda904..9e5ab41 100644 --- a/ShadowsocksX-NG/ServerProfileManager.swift +++ b/ShadowsocksX-NG/ServerProfileManager.swift @@ -2,7 +2,7 @@ // ServerProfileManager.swift // ShadowsocksX-NG // -// Created by 邱宇舟 on 16/6/6. Modified by 秦宇航 16/9/12 +// Created by 邱宇舟 on 16/6/6. Modified by 秦宇航 17/7/22 // Copyright © 2016年 qiuyuzhou. All rights reserved. // @@ -31,6 +31,13 @@ class ServerProfileManager: NSObject { return } } + if profiles.count == 0{ + let notice = NSUserNotification() + notice.title = "还没有服务器设定!" + notice.subtitle = "去设置里面填一下吧,填完记得选择呦~" + NSUserNotificationCenter.default.deliver(notice) + return + } activeProfileId = profiles[0].uuid }