ios - Handle Core Data Fetching Object Which No Longer Exists -


background info:

i have application accesses user's email account , fetches account data: emails, folders etc. process includes several steps, last of save or update newly fetched information core data. whole process start finish may take couple of seconds.

here problem:

  1. user opens application, fetching of new or updated account data process begins.
  2. user decides delete current account fetching occurring.
  3. a call sent cancel open fetch requests current account, however, fetch requests completed , core data trying save new data.
  4. while trying access "existing" core data objects in order update them, objects deleted , crash occurs.

specifically, error looks like:

coredata: annotation: logically false fetch request <nsfetchrequest: 0x13ce1430> (entity:     thread; predicate: (threadid == 1457719230395529203 , folder == <folder: 0xc1994c0> (entity: folder; id: 0xc2ccb20 <x-coredata://a0837e88-30eb-46e8-a9bc-d6699ec7f160/folder/p10> ; data: <fault>)); sortdescriptors: ((null)); type: nsmanagedobjectresulttype; ) short circuits. 

and crash occurring on line core data attempting fetch object no longer exists.

being new core data, wondering if there general strategy handling such circumstance.

you can separate kind of logical work on data model each major operation completes before next 1 started using operations on queue.

in specific case, sounds cancellation of current request isn't being handled correctly. should able stop pending operations once activity has been cancelled. may need add flag , check if activity cancelled after each asynchronous callback , before saving modifications.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -