Skip to content

Instantly share code, notes, and snippets.

@justingreerbbi
Created February 27, 2015 20:48
Show Gist options
  • Save justingreerbbi/0c3b66fbab7d34a9845f to your computer and use it in GitHub Desktop.
Save justingreerbbi/0c3b66fbab7d34a9845f to your computer and use it in GitHub Desktop.
//
// Simple NSDefaults Wrapper
//
// Created by Justin Greer on 2/27/15.
// Copyright (c) 2015 Justin Greer Interactive, LLC. All rights reserved.
//
import Foundation
class FCStorage {
let prefs: NSUserDefaults = NSUserDefaults.standardUserDefaults()
////////////////////////////////
// SET/GET STRING
////////////////////////////////
func setString ( key: String, value: String)
{
self.prefs.setObject(value, forKey: key)
}
func getString ( key: String ) -> String
{
return self.prefs.stringForKey( key )!
}
////////////////////////////////
// SET/GET BOOL
////////////////////////////////
func setBool ( key: String, value: Bool)
{
self.prefs.setObject(value, forKey: key)
}
func getBool ( key: String ) -> Bool
{
return self.prefs.boolForKey( key )
}
////////////////////////////////
// SET/GET INTEGER
////////////////////////////////
func setIntl ( key: String, value: Int)
{
self.prefs.setObject(value, forKey: key)
}
func getInt ( key: String ) -> Int
{
return self.prefs.integerForKey( key )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment