Reputation: 1208
I have an array of objects I'm currently storing in the documents directory in my app's sandbox. I'd like to have this data backed up to the users' cloud, and enable multiple users with the same iCloud account to share the data and enable push notifications if someone changes something. It's a budgeting app, so if your spouse buys something and enters the purchase into the app you would get a push notification. I've heard CloudKit is "so easy", so I thought that would be a good solution. I cannot figure out a good way to load this array of spending data into the Record structure.
For example, I have 100 transactions (each with a date, amount, and description). Right now they're stored in an array of a custom object SpendingData. Do I have to loop through all of these transactions and create unique records for each one in the Cloud dashboard? Won't that kill (or at least degrade) my app? Is there a better way to do this? Thanks!
Upvotes: 0
Views: 150
Reputation: 13127
I think the best way to handle these transactions is still a separate record for each transaction. Then when there is a new transaction you only have to write 1 record and your family members will get a push notification for only that new transaction. You could then include some data from that transaction in that push notification. something like: 'AAA added a new transaction for BBB'
To keep your app responsive, you should keep those transactions in memory and write them to disk (Core Data or file) so that on app restart you could load them and your app would have all data available without the need to wait for a fetch from the internet.
Upvotes: 1