1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- //
- // UserDefaultsConstant.swift
- // Learn Genie
- //
- // Created by Suraj Kumar Mandal on 31/08/21.
- //
- import Foundation
- class UserDefaultsConstant {
-
- class func getIntValueFromUserDefults(for key:String) -> Any?{
- let userDefault = UserDefaults.standard
- return userDefault.value(forKey: key)
- }
- class func setIntValueInUserDefaults(objValue:Int,for key:String){
- let userDefault = UserDefaults.standard
- userDefault.set(objValue, forKey: key)
- userDefault.synchronize()
- }
- class func getValueFromUserDefults(for key:String) -> Any?{
- let userDefault = UserDefaults.standard
- return userDefault.value(forKey: key)
- }
- class func setValueInUserDefaults(objValue:String,for key:String){
- let userDefault = UserDefaults.standard
- userDefault.set(objValue, forKey: key)
- userDefault.synchronize()
- }
- class func getBoolValueFromUserDefults(for key:String) -> Any?{
- let userDefault = UserDefaults.standard
- return userDefault.value(forKey: key)
- }
- class func setBoolValueInUserDefaults(objValue:Bool,for key:String){
- let userDefault = UserDefaults.standard
- userDefault.set(objValue, forKey: key)
- userDefault.synchronize()
- }
- class func setObjValueInUserDefaults(objValue:Data,for key:String){
- let userDefault = UserDefaults.standard
- userDefault.set(objValue, forKey: key)
- userDefault.synchronize()
- }
- class func getObjValueFromUserDefults(for key:String) -> Any?{
- let userDefault = UserDefaults.standard
- return userDefault.value(forKey: key)
- }
- class func removeValueFromUserDefults(for key:String){
- let userDefault = UserDefaults.standard
- return userDefault.removeObject(forKey:key)
- }
- class func deleteAllValuesFromUserDefaulst() {
- let domain = Bundle.main.bundleIdentifier!
- UserDefaults.standard.removePersistentDomain(forName: domain)
- UserDefaults.standard.synchronize()
- print("Deleted")
- }
-
- }
|