Foundation

Requirements

Installation

Carthage

To integrate Palau into your project using Carthage, add to your Cartfile:

github "symentis/Palau" ~> 1.0

Run carthage update to build the framework and drag the built Palau.framework into your Xcode project.
See more instructions on the Carthage page.

CocoaPods

To integrate Palau into your project using CocoaPods, add to your Podfile:

use_frameworks!
pod 'Palau', '~> 1.0'

Run pod install to install the framework into your Xcode workspace.

Usage

Import Palau

import Palau

Once you import the framework you can setup PalauDefaults like:

/// Your defaults are defined as extension of PalauDefaults
///
/// - The generic type of your PalauDefaultsEntry must conform
/// to the protocol PalauDefaultable.
/// - We provide support for the most common types.
/// - `value` is a helper function defined in PalauDefaults
/// - The String "backingName" is the key used in NSUserDefaults
/// - The empty `set` is used to please the compiler
extension PalauDefaults {
/// a NSUserDefaults Entry of Type String with the key "backingName"
public static var name: PalauDefaultsEntry<String> {
get { return value("backingName") }
set { }
}
}

Set

Every value of a PalauDefaultsEntry will always be optional.
If you want to set a value you call:

PalauDefaults.name.value = "I am a great String value!"

Get

Getting your value back is as easy as:

/// name is an Optional<String>
let name = PalauDefaults.name.value

Delete

You can delete a property by setting it to nil:

PalauDefaults.name.value = nil

Or

/// skip custom rules and delete
PalauDefaults.name.clear()

Custom Rules

Providing a Default Value

If you want to provide a default, when there is no value set,
you can write a custom rule. This allows fine granular control on
your values.