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