Archived
1

Version 1.0 of TagTunes.

This commit is contained in:
Kim Wittenburg
2015-09-03 00:22:33 +02:00
parent 3ab655b6c1
commit 1ad80062c4
55 changed files with 5235 additions and 65 deletions

View File

@@ -0,0 +1,69 @@
//
// Preferences.swift
// TagTunes
//
// Created by Kim Wittenburg on 29.08.15.
// Copyright © 2015 Kim Wittenburg. All rights reserved.
//
import Cocoa
/// A custom interface for the `NSUserDefaults`. It is recommended to use this
/// class insted of accessing the user defaults directly to prevent errors due
/// to misspelled strings.
///
/// All properties in this class are KCO compliant.
@objc public class Preferences: NSObject {
public static var sharedPreferences = Preferences()
/// Initializes the default preferences. This method must be called the very
/// first time the application is launched. It is perfectly valid to call
/// this method every time the application launches. Existing values are not
/// overridden.
public func initializeDefaultValues() {
let initialArtworkFolder = NSURL.fileURLWithPath(NSHomeDirectory(), isDirectory: true)
NSUserDefaults.standardUserDefaults().registerDefaults([
"Save Artwork": false,
"Keep Search Results": false,
"Remove Saved Albums": false])
if NSUserDefaults.standardUserDefaults().URLForKey("Artwork Target") == nil {
NSUserDefaults.standardUserDefaults().setURL(initialArtworkFolder, forKey: "Artwork Target")
}
}
/// If `true` the album artwork should be saved to the `artworkTarget` URL
/// when an item is saved.
public dynamic var saveArtwork: Bool {
set {
NSUserDefaults.standardUserDefaults().setBool(newValue, forKey: "Save Artwork")
}
get {
return NSUserDefaults.standardUserDefaults().boolForKey("Save Artwork")
}
}
/// The URL of the folder album artwork is saved to.
///
/// The URL must be a valid file URL pointing to a directory.
public dynamic var artworkTarget: NSURL {
set {
NSUserDefaults.standardUserDefaults().setURL(newValue, forKey: "Artwork Target")
}
get {
return NSUserDefaults.standardUserDefaults().URLForKey("Artwork Target")!
}
}
/// If `true` the search results are not removed from the main outline view
/// when the user selects a result.
public dynamic var keepSearchResults: Bool {
set {
NSUserDefaults.standardUserDefaults().setBool(newValue, forKey: "Keep Search Results")
}
get {
return NSUserDefaults.standardUserDefaults().boolForKey("Keep Search Results")
}
}
}