How to add to a number currently stored in user defaults Swift 4
问题 I want the user to be able to enter a new number and it will be added to what is currently saved in UserDefaults and then save that combined number in user defaults. Anyone have any idea how to do this? Thanks! Code: let typeHoursInt = Double(typeHours.text!)! let typePayInt = Double(typePay.text!)! totalMade.text = String(typeHoursInt * typePayInt) UserDefaults.standard.set(totalMade.text, forKey: "savedMoney") 回答1: This does what you ask. You should store your totalMade variable in User