// // 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") } }