Skip to content

Instantly share code, notes, and snippets.

@SURYAKANTSHARMA
Last active May 3, 2019 17:25
Show Gist options
  • Save SURYAKANTSHARMA/461fef7c86976c92a5cf254e40e40a9f to your computer and use it in GitHub Desktop.
Save SURYAKANTSHARMA/461fef7c86976c92a5cf254e40e40a9f to your computer and use it in GitHub Desktop.
Save User Balance
struct User {
let balance: Double
}
func saveUserBalance(user: User, buyingAmount: Double) {
let remainingBalance = user.balance - buyingAmount
// save user balance for persistance
UserDefaults.standard.set(remainingBalance, forKey: "userBalance")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment