Simple Swift file for store and retrieve User Defaults.
Simply copy and paste AppData File on your Project :)
AppData.storeData(data: "Hii", key: UserData(rawValue: UserData.postInfo.rawValue))
AppData.storeData(data: "Chathuranga", key: UserData(rawValue: UserData.userInfo.rawValue))
AppData.storeData(data: "Test", key: UserData(rawValue: UserData.commentInfo.rawValue))
You can add custome keys under UserData Enum type.
AppData.getData(key: .postInfo)
Use AppData.saveUserInformation(info: <#T##Decodable & Encodable#>, key: <#T##UserData.RawValue#>) for save data. eg :-
let myUser = User(name: "Chathuranga",
email: "chathu@gmail.com")
AppData.saveUserInformation(info: myUser, key: UserData.userInfo.rawValue)
Use AppData.retrieveUserInformation(key: <#T##UserData.RawValue#>, type: <#T##(Decodable & Encodable).Protocol#>) for retrieve data. eg :-
AppData.retrieveUserInformation(key: UserData.userInfo.rawValue, type: User.self)