Skip to content

Commit

Permalink
Merge pull request #117 from xing/plist_over_userdefaults
Browse files Browse the repository at this point in the history
Plist settings over UserDefaults
  • Loading branch information
JoeSSS authored Jan 10, 2018
2 parents f88b010 + 7ed8ded commit e548865
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 30 deletions.
20 changes: 0 additions & 20 deletions Launcher/Classes/ApplicationStateHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class ApplicationStateHandler {
case language = "testLanguage"
case tag = "testTag"
case debugState = "debugCheckboxState"
case cucumberProfile = "cucumberProfile"
case additionalRunParameters = "additionalRunParameters"
case deviceIP = "deviceIP"
case bundleID = "bundleID"
}
Expand Down Expand Up @@ -91,24 +89,6 @@ class ApplicationStateHandler {
}
}

var cucumberProfile: String? {
get {
return defaults.string(forKey: .cucumberProfile)
}
set {
defaults.set(newValue, forKey: .cucumberProfile)
}
}

var additionalRunParameters: String? {
get {
return defaults.string(forKey: .additionalRunParameters)
}
set {
defaults.set(newValue, forKey: .additionalRunParameters)
}
}

var deviceIP: String? {
get {
return defaults.string(forKey: .deviceIP)
Expand Down
13 changes: 5 additions & 8 deletions Launcher/Classes/ViewControllers/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ class SettingsViewController: NSViewController {
(linkField4, linkDescriptionField4)
]

if let cucumberProfile = applicationStateHandler.cucumberProfile {
if let cucumberProfile = plistOperations.readValues(forKey: Constants.Keys.cucumberProfileInfo).first {
cucumberProfileField.stringValue = cucumberProfile
}

if let additionalParameters = plistOperations.readValues(forKey: Constants.Keys.additionalFieldInfo).first {
additionalRunParameters.stringValue = additionalParameters
}

let linkArray = plistOperations.readKeys(forKey: Constants.Keys.linkInfo)
let linkDescriptionArray = plistOperations.readValues(forKey: Constants.Keys.linkInfo)

Expand All @@ -50,10 +54,6 @@ class SettingsViewController: NSViewController {
for (index, element) in linkDescriptionArray.enumerated() {
elements[index].1.stringValue = String(describing: element)
}

if let additionalParameters = applicationStateHandler.additionalRunParameters {
additionalRunParameters.stringValue = additionalParameters
}
}

@IBAction func clickProceedButton(_ sender: Any) {
Expand Down Expand Up @@ -99,9 +99,6 @@ class SettingsViewController: NSViewController {

plistOperations.create(from: resultingDictionary)

applicationStateHandler.cucumberProfile = cucumberProfileField.stringValue
applicationStateHandler.additionalRunParameters = additionalRunParameters.stringValue

// Reload build picker to get new elements
if
let tabViewController = NSApplication.shared.mainWindow?.contentViewController as? NSTabViewController,
Expand Down
4 changes: 2 additions & 2 deletions Launcher/Classes/ViewControllers/TasksViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ class TasksViewController: NSViewController {

arguments.append(calabashFolderPath)

if let cucumberProfile = applicationStateHandler.cucumberProfile, !cucumberProfile.isEmpty {
if let cucumberProfile = plistOperations.readValues(forKey: Constants.Keys.cucumberProfileInfo).first, !cucumberProfile.isEmpty {
arguments.append("-p \(cucumberProfile)")
}

Expand All @@ -394,7 +394,7 @@ class TasksViewController: NSViewController {
arguments.append("")
}

if let additionalRunParameter = applicationStateHandler.additionalRunParameters, !additionalRunParameter.isEmpty {
if let additionalRunParameter = plistOperations.readValues(forKey: Constants.Keys.additionalFieldInfo).first, !additionalRunParameter.isEmpty {
arguments.append("export \(additionalRunParameter)")
} else {
arguments.append("")
Expand Down

0 comments on commit e548865

Please sign in to comment.