//MARK: userDefaults 사용해보기
/*
1. 기존값을 불러온다.
2. 새로운 값을 저장한다. -> 까먹지마..
3. 새로운 값을 불러온다.
4. 텍스트 필드에 할당해준다
*/
//1.
let currentValue = UserDefaults.standard.integer(forKey: "emotionClickedCount\([sender.tag])")
// integer은 저장되는 값의 타입에 따라 달라진다~
//2.
let updateValus = currentValue + 1
//3.
UserDefaults.standard.set(updateValus, forKey: "emotionClickedCount\([sender.tag])")
//4.
buttonLabels[sender.tag].text = "\(emotionWords[sender.tag])\(UserDefaults.standard.integer(forKey: "emotionClickedCount\([sender.tag])"))"
'짤막 TlL' 카테고리의 다른 글
배경색 랜덤으로 바꾸기(CGFloat) (0) | 2022.07.21 |
---|---|
스토리보드 아이디 화면전환 안됨 (0) | 2022.07.21 |
alert 코드 조각 (0) | 2022.07.21 |
alert cancel (0) | 2022.07.21 |
코드 접어놓기 (0) | 2022.07.16 |