-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not always persisting #9
Comments
Can you reproduce this with a sample project? I only ask because I'm not quite sure what the internals of SignUpView might be doing for instance |
Unable to reproduce with the following code, seems to save correctly. Please let me know if you have sample/code project and I'm happy to look into it. import SwiftUI
import TinyStorage
struct ContentView: View {
var body: some View {
SettingsView()
}
}
struct AuthUserMeta: Codable {
var userName: String
let createdAt: Date?
var karma: Int?
}
struct SettingsView: View {
@State var showSignIn = false
@TinyStorageItem(AppStorageKey.authUserMeta, storage: .appGroup)
var userInfo = AuthUserMeta(userName: "", createdAt: nil, karma: nil)
var body: some View {
VStack {
Form {
Section {
Button(
action: {
showSignIn = true
},
label: {
Text("Sign In")
})
}
}
}
.sheet(isPresented: $showSignIn) {
VStack {
Text("Stored Value: \(userInfo.userName)")
TextField("Message", text: $userInfo.userName)
}
}
}
}
enum AppStorageKey: String, TinyStorageKey {
case authUserMeta
case lastFullStorySync
}
extension TinyStorage {
static let appGroup: TinyStorage = {
let appGroupID = "group.com.christianselig.apollo"
let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupID)!
return .init(insideDirectory: containerURL, name: "tiny-storage-general-prefs")
}()
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can't reproduce on the simulator, but on my phone I'm running into a weird issue where the data doesn't persist when I force close the app.
My setup is:
So then if I open this view, fill out the form and then force close the app, it doesn't have the data when I reopen the app
if I don't force close the app, then the data sticks around for a while before disappearing
Previously I was using a handful of
@AppStorage(AppStorageKeys.authedUserName)
TinyStorage: 1.0.16
The text was updated successfully, but these errors were encountered: