You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
State 와 StateObject의 lifetime.
List를 쓸 때 종종 상태가 날아가는 경우가 생김.
StateObject의 라이프 타임 테스트
StateObjectItemTest는 StateObject를 들고 있고 이걸 List로 뿌려봅시다.
finalclassMyObject:ObservableObject{init(){print("Allocating")}}structStateObjectItemTest:View{@StateObjectprivatevarobject=MyObject()letbody=Text("Hello")}
// 컨테이너 뷰가 있다고 치고
List(0..<1000){ id inStateObjectItemTest()}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
주간 스티브
주간 Steve 뉴스 23.11.06. TL;DR 1.ForEach 달러 달러 조심해서 사용해야 함. 2… | by woozoobro | Nov, 2023 | Medium
OpenAI 키노트
https://www.youtube.com/watch?v=U9mJuUkhUzk
맥 os 앱 오픈소스
https://github.com/p0deje/Maccy
맷씨는 클립보드 앱
https://github.com/superhighfives/pika
피카는 칼라 피커 앱
Point free 강의
TCA referral 로 가입하면 둘 다 한달 공짜 크레딧 줌
https://www.pointfree.co/subscribe/personal?ref=H4GUzc9i
친구 없으신 분은 제걸로
SwiftUI State Properties
https://chris.eidhof.nl/post/swiftui-state-lifetime/
State 와 StateObject의 lifetime.
List를 쓸 때 종종 상태가 날아가는 경우가 생김.
StateObject의 라이프 타임 테스트
StateObjectItemTest는 StateObject를 들고 있고 이걸 List로 뿌려봅시다.
프린트문 확인해보면 화면에 보여지는 것만 우선 그리고 있으
@State로 테스트 해도 마찬가지.
스크롤을 내리면 새로운 State들이 할당되죠
그럼 언제 이 상태들이 없어질까?
카운트 값인 counter를 @State로 가진 버튼이 있다고 해보자.
카운트 올리고 스크롤을 했다가
보이지 않게 한 다음에 다시 보이게 하면?
상태가 정상적으로 저장되고 있습니다.
방금의 Item을 ItemWrapper라는 래퍼뷰로 한번 감싸줘보자.
??
상태가 사라짐
Beta Was this translation helpful? Give feedback.
All reactions