Skip to content

Commit 182ed3f

Browse files
committed
Presenting a message when bindings are succesfully installed.
1 parent 0b03978 commit 182ed3f

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

Import/Controller/KeyBindingsInserter.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class KeyBindingsInserter {
5454
//check if there is already a plist entry and replace it.
5555
if bindingPosition != NSNotFound {
5656
if isBindingSet(in: bindings[bindingPosition] as! NSDictionary) {
57-
present(message: "Binding is already set.\nImport is ready to be used in Xcode.")
57+
present(message: "Binding is already set.\nImport is ready to be used in Xcode.", style: .informational)
58+
return;
5859
}
5960
else {
6061
bindings.removeObject(at: bindingPosition)
@@ -66,6 +67,7 @@ class KeyBindingsInserter {
6667
}
6768

6869
existingPlist.write(toFile: path, atomically: true);
70+
present(message: "Binding ⌘ + ctrl + P is now set in Xcode.", style: .informational)
6971
}
7072

7173
private func position(in bindings:NSMutableArray) -> Int {
@@ -89,27 +91,23 @@ class KeyBindingsInserter {
8991
private func installVanillaPlist() {
9092
do {
9193
try FileManager.default.copyItem(atPath: vanillaPlistPath, toPath: path)
94+
present(message: "Binding ⌘ + ctrl + P is now set in Xcode.", style: .informational)
9295
}
9396
catch let error as NSError {
9497
present(error: error)
9598
}
9699
}
97100

98-
private func present(message: String) {
99-
let myPopup = NSAlert()
100-
myPopup.messageText = "👍"
101-
myPopup.informativeText = message
102-
myPopup.alertStyle = .informational
103-
myPopup.addButton(withTitle: "OK")
104-
myPopup.runModal()
101+
private func present(message: String, style: NSAlertStyle) {
102+
let alert = NSAlert()
103+
alert.messageText = (style == .informational) ? "👍" : "🤕"
104+
alert.informativeText = message
105+
alert.alertStyle = style
106+
alert.addButton(withTitle: "OK")
107+
alert.runModal()
105108
}
106109

107110
private func present(error: NSError) {
108-
let myPopup = NSAlert()
109-
myPopup.messageText = "Something went wrong 🤕"
110-
myPopup.informativeText = error.localizedDescription
111-
myPopup.alertStyle = .critical
112-
myPopup.addButton(withTitle: "OK")
113-
myPopup.runModal()
111+
present(message: error.localizedDescription, style:.critical)
114112
}
115113
}

0 commit comments

Comments
 (0)