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 |
Tags
- Responder chain
- delays deallocation
- Combine
- weak self
- readLine
- async
- input
- MaxHeap
- reversed
- 사내배포
- AVCaptureSession
- Custom Class
- binder
- URLSession
- DISPATCH
- moya
- hitTest
- 입력
- swift
- BidirectionalCollection
- 공백
- Asnyc
- 전자출입
- ReactorKit
- ios
- RxSwift
- UIResponder
- Python
- vtable
- UserDefaults
Archives
- Today
- Total
목록Custom Class (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