Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- input
- ReactorKit
- Python
- vtable
- hitTest
- reversed
- Responder chain
- DISPATCH
- moya
- Asnyc
- swift
- BidirectionalCollection
- Custom Class
- UserDefaults
- delays deallocation
- RxSwift
- async
- binder
- 입력
- weak self
- ios
- AVCaptureSession
- readLine
- Combine
- UIResponder
- 공백
- URLSession
- 사내배포
- MaxHeap
- 전자출입
Archives
- Today
- Total
목록UserDefaults (1)
틈틈히 적어보는 개발 일기
[iOS][Swift] 커스텀 클래스를 UserDefaults에 저장해보기, Singleton 패턴 적용하기
결론 원하는 Class에 NSObject, NSCoding을 채택 후 각각의 변수들에 decode, encode 메소드를 작성해줍니다. class PTimer: NSObject, NSCoding { var time: Int = -1 var name: String = "Timer" required init?(coder: NSCoder) { self.time = coder.decodeInteger(forKey: "time") // 문자열은 Object로 불러와 String으로 타입캐스팅 해준다 self.name = coder.decodeObject(forKey: "name") as? String } func encode(with coder: NSCoder) { coder.encode(self.time, fo..
📱 iOS, Swift
2021. 1. 5. 23:00