Post

Replies

Boosts

Views

Activity

Can the NSPersistentCloudKitContainer mirror the data from the cloudKit public database to the local Core Data if the user is not logged in?
I'm currently syncing Core Data with the CloudKit public database using NSPersistentCloudKitContainer. The app starts with an empty Core Data store locally and at the app launch it downloads the data from CloudKit public database to the Core Data store, but this can only be accomplished if the user is logged in, if the user is not logged, no data gets downloaded and I get the error below. Can the NSPersistentCloudKitContainer mirror the data from the CloudKit public database to the local Core Data even if the user is not logged in? Can someone please confirm this is possible? The reason for my question is because I was under the impression that the users didn't need to be logged to read data from the public database in CloudKit but I'm not sure this applies to NSPersistentCloudKitContainer when mirroring data. I know I can fetch data directly with CloudKit APIs without the user beign logged but I need to understand if NSPersistentCloudKitContainer should in theory work without the user being logged. I hope someone from Apple sees this question since I have spent too much time researching without any luck. Error Error fetching user record ID: <CKError 0x600000cb1b00: "Not Authenticated" (9); "No iCloud account is configured"> CoreData: error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(1192): <NSCloudKitMirroringDelegate: 0x600003b00460>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x10700f0d0> (URL: file:///Users/UserName/...
4
0
975
Jun ’24
What would be the best logic for updating a file periodically after an app has been released
I have a code that needs to be ran about every year to update some files at the app launch and I'm trying to come up with the best way to do that. What I need to be able to basically force the app to run the code whenever I need to update the files. This is what I came up with that I think would work but I'm not sure if that's the best way. Are there any other options to handle this type of logic? App version 1 - INITIAL RELASE. This code would work as long as I don't add an update. // First launch @main struct SwifUIPlayGroundApp: App { @AppStorage("shouldLoad") var shouldLoad = true init(){ if shouldLoad{ print("Loading...") shouldLoad = false }else{ print("No need to relaod...") } } } App version 2 - UPDATE 1. Here I would need to add a second variable to force the update shouldUpdate. I would also need to change the logic to check for the shouldUpdate instead of the shouldLoad and set the shouldLoad to true to be prepared for future updates. // UPDATE 1 @main struct SwifUIPlayGroundApp: App { @AppStorage("shouldUpdate") var shouldUpdate = true // new @AppStorage("shouldLoad") var shouldLoad = true init(){ if shouldUpdate{ print("Loading...") shouldUpdate = false shouldLoad = true // prepare for next update }else{ print("No need to relaod...") } } } App version 3 - UPDATE 2. Here I would need to change the logic back to check for the shouldLoad instead of the shouldUpdate and set the shouldUpdate to true to be prepared for future updates. // UPDATE 2 @main struct SwifUIPlayGroundApp: App { @AppStorage("shouldUpdate") var shouldUpdate = true @AppStorage("shouldLoad") var shouldLoad = true init(){ if shouldLoad{ print("Loading...") shouldUpdate = true // prepare for next update shouldLoad = false }else{ print("No need to relaod...") } } } App version 4 - UPDATE 3. Repeat what I did in UPDATE 1...
7
0
1.5k
Jan ’23