1

I have what I perceive to be a relatively complicated data model, with multiple many-to-many relationships that are necessary in order to get the functionality that I want. Without iCloud everything works great: CPU low, memory usage usually around 15 mb/s, maximum of 30.

I've implemented bare bones iCloud Core Data syncing following Tim Roadley's wonderfully helpful tutorial found here http://timroadley.com/2012/04/03/core-data-in-icloud/

  1. First question: when first opening the app, there's sometimes a lag in which data stored cannot be accessed. I do a NSFetchRequest and get back an empty array. After a few seconds I can retrieve data.

    Why is this happening? I thought with iCloud enabled in Xcode 5, two data stores were being made, one for local use and one for iCloud use? should not the local store be accessible?

    I've gotten around the first bit by having a 'portal' view controller, so that the lag can (in most cases) be overcome (sometimes you see a blank TVC.. not happy)

  2. Second question, and the more pressing one: after a few seconds (usually around 15) something happens in a background thread, CPU usage shoots to 99% and memory goes way up from 10 - about 100 mb/s. It remains that high - it doesn't go up (nor does it crash), and it doesn't go down for the remainder of usage (I mean at least the 2 hours I've had it constantly running). No crashing! just kinda laggy interface interaction.

    Why is this happening and how can I solve it?

I don't have a great understanding of how iCloud syncing works; somehow transaction logs are made, stored as plists, and sent out somewhere and something happens. What I'm assuming is that the transaction logs I have are really big- perhaps due to the several many-to-many relationships I have? This question suggests as such (there is no solution to his problem, and I also don't have the ever-increasing memory usage: mine stops at a certain point): Core Data with iCloud causing low memory warnings and crashes, memory usage constantly grows

thoughts: - If it were the transaction logs, shouldn't they be deleted at some point? say after the log has been uploaded to icloud? why does it just sit there taking up space? - Is there any way to define the times in which syncing is done? or manually delete the transaction log? Has anyone experienced this/ solved it?

Community
  • 1
  • 1

1 Answers1

0

Josh,

You not posted any code; so giving advise is somewhat hit&miss. Assuming you have a completion block in your fetch request, are you sure the lag its't simply the time it takes to get the data from iCloud. Somewhat confusing but explained in this tread, iCloudKit does not cache any data locally, it is simply a transport mechanism.

Using Core Data, iCloud and CloudKit for syncing and backup and how it works together

Your CPU issue I suspect is iCloudKit related, it is quite possible to issue multiple requests/threads to iCloudKit. Look at my question on, the code here for a calling sequence, if you are looping around your iCloudKit code, calling itself within itself you will surely see the behaviour you describe.

CKFetchRecordsOperation + CKQueryOperations ... what am I missing?

Community
  • 1
  • 1
user3069232
  • 8,587
  • 7
  • 46
  • 87