Sort presets by title.

This commit is contained in:
Damiano Galassi committed 2017-08-28 16:47:26 +02:00
1 parent 107c9273fd
commit d3dd741660
1 file changed
+6
+6
View File
@@ -53,6 +53,7 @@ extension PresetManager.Error: LocalizedError {
throw Error.alreadyExists
}
presets.append(newElement)
sort()
postNotification()
}
@@ -67,6 +68,10 @@ extension PresetManager.Error: LocalizedError {
return presets.filter { $0.title == name }.first
}
private func sort() {
presets.sort { return $0.title.localizedCompare($1.title) == ComparisonResult.orderedAscending }
}
private func postNotification() {
NotificationCenter.default.post(name: updateNotification, object: self)
}
@@ -138,6 +143,7 @@ extension PresetManager.Error: LocalizedError {
}
catch {}
}
sort()
}
private func save(preset: Preset, to url: URL) throws {