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
- xml delegate
- spring guide
- Structural Identity
- schemes
- swift
- lifecycle
- ios
- developer
- bounds이해
- native개발
- Quick Help
- view
- Explict Identity
- WWDC21
- 적절한 사용방법
- Identity
- Lifetime of SwiftUI
- Demystify SwiftUI
- lazy 사용
- lazy 위험성
- frame이해
- Xcode
- Lazy
- ios login
- git branch strategy
- Your app is missing support for the following URL schemes: your_ios_client_id
- 보라색오류
- Spring
- consuming a restful web service
- TabBarItems
Archives
- Today
- Total
목록적절한 사용방법 (1)
Dev_Dylan

공식문서에서 Lazy Property 위험하다는 주석이 달려있다. Note lazy 수식어가 표시된 프로퍼티는 여러 스레드에서 동시에 접근되고 프로퍼티가 아직 초기화되지 않은 경우 프로퍼티가 한 번만 초기화된다는 보장이 없습니다. 그래서 보장이 안되는 경우가 언제인가? 언제 두번이상 초기화 되고 이상하게 쓰일까? 왜 쓰면 안되는데?? 의문을 품고, 여러 스레드에서 동시에 접근될 때 정말 초기화가 잘 이루어지지 않는지 코드로 구현해 보았다. import Foundation class Example { lazy var myLazyProperty: String = { print("Initializing lazy property") return "Hello, Lazy! : \\(Int.random(in: 1....
iOS/iOS_Swift
2024. 1. 13. 23:57