From 70f9ac6f2984f0a35453b23822915a60183cdea0 Mon Sep 17 00:00:00 2001 From: Shengye Wang Date: Mon, 1 Feb 2021 19:46:32 -0800 Subject: [PATCH] Use NSDictionary to implement getPlistKey. If the value is UTF-8 (e.g. Chinese characters), "defaults read" would escape it. This patch would allow UTF-8 plist values to be read. --- AppSigner/MainView.swift | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/AppSigner/MainView.swift b/AppSigner/MainView.swift index e0db409..ade438d 100644 --- a/AppSigner/MainView.swift +++ b/AppSigner/MainView.swift @@ -437,12 +437,8 @@ class MainView: NSView, URLSessionDataDelegate, URLSessionDelegate, URLSessionDo return "\(size)B" } @objc func getPlistKey(_ plist: String, keyName: String)->String? { - let currTask = Process().execute(defaultsPath, workingDirectory: nil, arguments: ["read", plist, keyName]) - if currTask.status == 0 { - return String(currTask.output.dropLast()) - } else { - return nil - } + let dictionary = NSDictionary(contentsOfFile: plist); + return dictionary?[keyName] as? String } func setPlistKey(_ plist: String, keyName: String, value: String)->AppSignerTaskOutput {