<commit_before>//
//  Defaults.swift
//  Padiddle
//
//  Created by <NAME> on 9/18/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation

private let colorPickerPersistentIndexKey = "ColorPickerIndex"

#if SCREENSHOTS
let defaultColorPickerPersistentIndex = 6
    #else
let defaultColorPickerPersistentIndex = 0
#endif

struct Defaults {
    static var colorPickerSelection: Int {
        get {
            var restoredValue: Int?
            let objectExists = NSUserDefaults().objectForKey(colorPickerPersistentIndexKey) != nil
            if objectExists {
                restoredValue = NSUserDefaults().integerForKey(colorPickerPersistentIndexKey)
            } else {
                restoredValue = defaultColorPickerPersistentIndex
            }

            return restoredValue!
        }
        set(newSelection) {
            NSUserDefaults().setInteger(newSelection, forKey: colorPickerPersistentIndexKey)
        }
    }
}<commit_msg>More concise NSUserDefaults code through optionals.<commit_after>//
//  Defaults.swift
//  Padiddle
//
//  Created by <NAME> on 9/18/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

import Foundation

private let colorPickerPersistentIndexKey = "ColorPickerIndex"

#if SCREENSHOTS
let defaultColorPickerPersistentIndex = 6
    #else
let defaultColorPickerPersistentIndex = 0
#endif

struct Defaults {
    static var colorPickerSelection: Int {
        get {
            return (NSUserDefaults().objectForKey(colorPickerPersistentIndexKey) as? Int) ?? defaultColorPickerPersistentIndex
        }
        set(newSelection) {
            NSUserDefaults().setInteger(newSelection, forKey: colorPickerPersistentIndexKey)
        }
    }
}
{'fraction_non_alphanumeric': 0.0822637106184364, 'fraction_numerical': 0.012835472578763127, 'mean_word_length': 2.871331828442438, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7573676', 'n_tokens_mistral': 493, 'n_tokens_neox': 461, 'n_words': 110}