<commit_before># SwiftyUserDefaults 2.0

**SwiftyUserDefaults** makes `NSUserDefaults` cleaner, nicer and easier to use in Swift. Its statically-typed API gives you extra safety and convenient compile-time checks for free.

Read [Swifty APIs: NSUserDefaults](http://radex.io/swift/nsuserdefaults/) and [Statically-typed NSUserDefaults](http://radex.io/swift/nsuserdefaults/static) for more information about this project.

### Define your keys

To get the most out of SwiftyUserDefaults, we recommend defining your user defaults keys ahead of time:

```swift
let colorKey = DefaultsKey<String>("color")
```

Just create a `DefaultsKey` object, put the value type in square bracket and the key name in parentheses and you're good to go.

You can now use the global `Defaults` object:

```swift
Defaults[colorKey] = "red"
Defaults[colorKey] // => "red", typed as String
```

The compiler won't let you set a wrong value type, and fetching conveniently returns `String` — no need for manual casting or special accessors.

### Take shortcuts

For extra convenience, define your keys by extending `DefaultsKeys` and adding static properties:

```swift
extension DefaultsKeys {
    static let username = DefaultsKey<String?>("username")
    static let launchCount = DefaultsKey<Int>("launchCount")
}
```

And use the shortcut dot syntax:
<commit_msg>Fixed tiny typo.<commit_after># SwiftyUserDefaults 2.0

**SwiftyUserDefaults** makes `NSUserDefaults` cleaner, nicer and easier to use in Swift. Its statically-typed API gives you extra safety and convenient compile-time checks for free.

Read [Swifty APIs: NSUserDefaults](http://radex.io/swift/nsuserdefaults/) and [Statically-typed NSUserDefaults](http://radex.io/swift/nsuserdefaults/static) for more information about this project.

### Define your keys

To get the most out of SwiftyUserDefaults, we recommend defining your user defaults keys ahead of time:

```swift
let colorKey = DefaultsKey<String>("color")
```

Just create a `DefaultsKey` object, put the value type in angled brackets and the key name in parentheses and you're good to go.

You can now use the global `Defaults` object:

```swift
Defaults[colorKey] = "red"
Defaults[colorKey] // => "red", typed as String
```

The compiler won't let you set a wrong value type, and fetching conveniently returns `String` — no need for manual casting or special accessors.

### Take shortcuts

For extra convenience, define your keys by extending `DefaultsKeys` and adding static properties:

```swift
extension DefaultsKeys {
    static let username = DefaultsKey<String?>("username")
    static let launchCount = DefaultsKey<Int>("launchCount")
}
```

And use the shortcut dot syntax:

{'fraction_non_alphanumeric': 0.0924962852897474, 'fraction_numerical': 0.0014858841010401188, 'mean_word_length': 5.176605504587156, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6996748', 'n_tokens_mistral': 796, 'n_tokens_neox': 726, 'n_words': 320}