Last active
May 3, 2019 17:25
-
-
Save SURYAKANTSHARMA/461fef7c86976c92a5cf254e40e40a9f to your computer and use it in GitHub Desktop.
Save User Balance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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