Replies: 2 comments 1 reply
-
정리 감사합니다 모수!ㅎㅎ struct ContentView: View {
@AppStorage("isOnboarding") var isOnboarding: Bool = false
var body: some View {
VStack {
Text("온보딩입니다:)")
Button {
isOnboarding = false
} label: {
Text("온보딩 종료")
}
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
첨언하자면, 결론적으로, User Defaults 같이 환경설정을 위해서는 아주 간편한 방법이지만, 계속 쌓여나가는 사용자의 데이터를 저장하기는 부적합합니다. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
안녕하세요! 3기 오전 세션 러너 Mosu입니다~!!
디바이스에 값을 저장할 때 UserDefaults도 사용할 수 있습니다.
SwiftData처럼 모델간 관계 정의나 기타 편의 기능 등을 사용하진 못하지만, 단순하게 데이터를 저장하기에는 이게 더 편합니다!
SwiftUI에서는
@AppStorage
라는 프로퍼티 래퍼를 사용해서 더더욱 쉽게 사용할 수 있습니다.기존에 사용하던
@State
자리에@AppStorage("키 이름")
를 넣어주시면 바로 사용하실 수 있습니다.(내부적으로 .plist 파일에 해당 내용을 기록하기 때문에 추출이 매우 쉽습니다. 개인정보를 담지 않도록 주의하세요!)
그럼 모두 NC1 화이팅입니다!!
Beta Was this translation helpful? Give feedback.
All reactions