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 |
Tags
- spring guide
- xml delegate
- lazy 위험성
- git branch strategy
- 적절한 사용방법
- 보라색오류
- consuming a restful web service
- swift
- Demystify SwiftUI
- Xcode
- Spring
- Explict Identity
- Identity
- frame이해
- native개발
- WWDC21
- schemes
- ios
- Lifetime of SwiftUI
- SwfitUI
- Your app is missing support for the following URL schemes: your_ios_client_id
- TabBarItems
- Lazy
- mvc cocoa
- lazy 사용
- view
- bounds이해
- ios login
- Quick Help
- Structural Identity
Archives
- Today
- Total
Dev_Dylan
iOS_ViewController buttons를 array에 [Lazy] 본문
ViewController에 버튼을 추가해서 배열에 담기
최초
StoryBoard 에서도
혹은, 코드로 UIButton을 선언해도
같은 오류가 난다.
Cannot use instance member 'button' within property initializer; property initializers run before 'self' is available
오류 코드에 보면
[인스턴스 맴버인 버튼을 초기화 없이 사용 할 수 없다]
라고 나온다.
Lazy 키워드로 해결
buttons 배열에 lazy를 사용해서 ERROR를 해결한다.
lazy키워드를 이용해 동시에 호출되는 것을 방지한다.
즉, 각각의 button1,button2,button3 와
이를 포함하는 [buttons] 배열을 동시에 호출되지 않도록
lazy var buttons 를 이용해서 배열이 사용 될 때에 호출 되도록 하는 것.
https://developer.apple.com/documentation/foundation/indexpath/1780078-lazy/
button 뿐만아니라 다른 타입들에서도 마찬가지로, class 내에서 생성 할 때 유의하면 된다.
VCLifeCycle, 객체LifeCycle 에 대해 이해하자.!
'iOS > Solve_ERROR' 카테고리의 다른 글
[iOS]Google Login 스키마 추가(with error) (0) | 2024.03.08 |
---|---|
[iOS] HTTP 접근 허용. (ATS_App Transport Security) (0) | 2024.01.10 |
[iOS] FatalError는 어떻게 써야할까? (with 에러처리) (1) | 2023.12.10 |
iOS_PickerView question mark (debug) (0) | 2022.04.09 |
Comments