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
- UITextView
- scrollview
- map
- rxswift
- swiftUI
- ribs
- Xcode
- HIG
- 애니메이션
- SWIFT
- collectionview
- Human interface guide
- RxCocoa
- Clean Code
- 스위프트
- uiscrollview
- combine
- clean architecture
- 클린 코드
- 리펙토링
- Observable
- uitableview
- MVVM
- UICollectionView
- Protocol
- 리팩토링
- Refactoring
- tableView
- ios
- swift documentation
Archives
- Today
- Total
김종권의 iOS 앱 개발 알아가기
[iOS - swift] weak var 사용방법 ('weak' must not be applied to non-class-bound) 본문
iOS 기본 (swift)
[iOS - swift] weak var 사용방법 ('weak' must not be applied to non-class-bound)
jake-kim 2021. 4. 29. 23:28weak var 프로퍼티
- retain cycle을 방지하기 위해서 weak var사용
- weak var는 보통 delegate와 같이 delegate 객체가 사라지면 ARC에서 자동으로 nil을 할당할수 있도록 메모리 관리에 사용
weak var 타입
- weak var를 사용하려는 타입이 만약 protocol일 경우, AnyObject를 상속받지 않으면 오류 발생
- 'weak' must not be applied to non-class-bound
- 프로토콜은 클래스와 구조체, 열거형에 사용되는데, 이 프로토콜이 어디에 사용될지 모르니 reference count 관리를 위해 사용되는 unowned나 weak 키워드 사용 불가
- protocol에 AnyObject를 상속받아서 사용하면, 클래스임 정의하기 때문에 weak 키워드 사용 가능
'iOS 기본 (swift)' 카테고리의 다른 글
| [iOS - swift] xib 사용원리 (archive, unarchive), encode, decode, NSCoder (0) | 2021.05.19 |
|---|---|
| [iOS - swift] ARC, strong, unowned, weak (실무 관점) (0) | 2021.05.03 |
| [iOS - swift] ~= 연산자 (범위 연산자) (0) | 2021.04.08 |
| [iOS - swift] Argument Labels vs Parameter (0) | 2021.04.08 |
| [iOS - swift] 타입 캐스팅 (업 캐스팅 vs 다운 캐스팅) (0) | 2021.04.08 |
Comments
