I can save and retrieve deleted mails number (such as like Integer value) in UserDefaults
. Suppose if I deleted some more mails then I have to add/increase that saved UserDefaults
value and if I retrieve it should come total deleted mails number. ->> Here numEmails
is deleted mails number(Integer).
UserDefaults.standard.set(numEmails, forKey: "NumberofMailsDeleted") //Saving
var numMailsDeleted = UserDefaults.standard.integer(forKey: "NumberofMailsDeleted") //Retriving
print("I've deleted \(numMailsDeleted) mails") //Printing`
I will explain this scenario with other example ->> I want to save vehicles incoming (number of vehicles inside) into the parking area (i.e. the UserDefaults
saved value is changing according to the cars incoming). If I retrieve it should come updated value of incoming don't think about outgoing, I don't need outgoing