AutorÃa | Ultima modificación | Ver Log |
//// PreferenceModel.swift// twogetskills//// Created by Efrain Yanez Recanatini on 3/3/22.//import Foundationclass Preference {let standardPreference = UserDefaults.standardvar deviceUuid : Stringvar userUuid : Stringvar fcmToken : Stringvar email : Stringvar firstName : Stringvar lastName : Stringvar image : Stringvar password : Stringvar aes : Stringvar maxDateChanges : Stringvar viewIdxActive: Intvar topicUuidActive : Stringvar capsuleUuidActive : Stringvar slideUuidActive : Stringvar companyUuidActive : Stringvar companyCount : Intvar capsuleUuidOld : Stringstatic let sharedInstance: Preference = {let instance = Preference()// setup codereturn instance}()private init() {self.deviceUuid = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_DEVICE_ID) ?? ""self.userUuid = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_USER_ID) ?? ""self.fcmToken = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_FCM_TOKEN) ?? ""self.email = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_EMAIL) ?? ""self.firstName = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_FIRST_NAME) ?? ""self.lastName = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_LAST_NAME) ?? ""self.image = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_IMAGE) ?? ""self.password = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_PASSWORD) ?? ""self.aes = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_AES) ?? ""self.maxDateChanges = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_MAX_DATE_CHANGES) ?? ""self.viewIdxActive = standardPreference.integer(forKey: Constants.PREFERENCE_FIELD_VIEW_IDX_ACTIVE)self.topicUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_TOPIC_UUID_ACTIVE) ?? ""self.capsuleUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_CAPSULE_UUID_ACTIVE) ?? ""self.slideUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_SLIDE_UUID_ACTIVE) ?? ""self.companyUuidActive = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_COMPANY_UUID_ACTIVE) ?? ""self.companyCount = standardPreference.integer(forKey: Constants.PREFERENCE_FIELD_COMPANY_COUNT) ?? 0self.capsuleUuidOld = standardPreference.string(forKey: Constants.PREFERENCE_FIELD_CAPSULE_UUID_OLD) ?? ""}func save() -> Void {standardPreference.setValue(deviceUuid, forKey: Constants.PREFERENCE_FIELD_DEVICE_ID)standardPreference.setValue(userUuid, forKey: Constants.PREFERENCE_FIELD_USER_ID)standardPreference.setValue(fcmToken, forKey: Constants.PREFERENCE_FIELD_FCM_TOKEN)standardPreference.setValue(email, forKey: Constants.PREFERENCE_FIELD_EMAIL)standardPreference.setValue(firstName, forKey: Constants.PREFERENCE_FIELD_FIRST_NAME)standardPreference.setValue(lastName, forKey: Constants.PREFERENCE_FIELD_LAST_NAME)standardPreference.setValue(image, forKey: Constants.PREFERENCE_FIELD_IMAGE)standardPreference.setValue(password, forKey: Constants.PREFERENCE_FIELD_PASSWORD)standardPreference.setValue(aes, forKey: Constants.PREFERENCE_FIELD_AES)standardPreference.setValue(maxDateChanges, forKey: Constants.PREFERENCE_FIELD_MAX_DATE_CHANGES)standardPreference.setValue(viewIdxActive, forKey: Constants.PREFERENCE_FIELD_VIEW_IDX_ACTIVE)standardPreference.setValue(topicUuidActive, forKey: Constants.PREFERENCE_FIELD_TOPIC_UUID_ACTIVE)standardPreference.setValue(capsuleUuidActive, forKey: Constants.PREFERENCE_FIELD_CAPSULE_UUID_ACTIVE)standardPreference.setValue(slideUuidActive, forKey: Constants.PREFERENCE_FIELD_SLIDE_UUID_ACTIVE)standardPreference.setValue(companyUuidActive, forKey: Constants.PREFERENCE_FIELD_COMPANY_UUID_ACTIVE)standardPreference.setValue(companyCount, forKey: Constants.PREFERENCE_FIELD_COMPANY_COUNT)standardPreference.setValue(capsuleUuidOld, forKey: Constants.PREFERENCE_FIELD_CAPSULE_UUID_OLD)standardPreference.synchronize()}}