add examplejson to Xcode project file

add examplejson to Xcode project file
fix resource method
This commit is contained in:
qinyuhang
2017-01-10 15:02:54 +08:00
parent 15193a978d
commit 1e4ad0b108
2 changed files with 7 additions and 16 deletions

View File

@ -99,8 +99,8 @@ class ServerProfileManager: NSObject {
profile.remark = item["remarks"] as! String
self.profiles.append(profile)
self.save()
NotificationCenter.default.post(name: NSNotification.Name(rawValue: NOTIFY_SERVER_PROFILES_CHANGED), object: nil)
}
NotificationCenter.default.post(name: NSNotification.Name(rawValue: NOTIFY_SERVER_PROFILES_CHANGED), object: nil)
let configsCount = (jsonArr1.object(forKey: "configs") as! [[String: AnyObject]]).count
let notification = NSUserNotification()
notification.title = "Import Server Profile succeed!".localized
@ -123,7 +123,7 @@ class ServerProfileManager: NSObject {
//exampleconfigsNSDictionaryconfigs
let fileManager = FileManager.default
let filePath:String = Bundle.main.bundlePath + "/Contents/Resources/example-gui-config.json"
let filePath:String = Bundle.main.path(forResource: "example-gui-config", ofType: "json")!
let data = fileManager.contents(atPath: filePath)
let readString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)!
let readStringData = readString.data(using: String.Encoding.utf8.rawValue)
@ -168,7 +168,7 @@ class ServerProfileManager: NSObject {
class func showExampleConfigFile() {
//copy file to ~/Downloads folder
let filePath:String = Bundle.main.bundlePath + "/Contents/Resources/example-gui-config.json"
let filePath:String = Bundle.main.path(forResource: "example-gui-config", ofType: "json")!
let fileMgr = FileManager.default
let dataPath = NSHomeDirectory() + "/Downloads"
let destPath = dataPath + "/example-gui-config.json"