ios - Core Data Concurrency with parent/child relationship and NSInvocationOperation done right? -


i've been using core data store ios app data in sqlite db. data synchronized central server during login or after n minutes have passed , app grew, synchronization got slower , needed background process prevent freezing of main thread.

for rewrote synchronization class use nsinvocationoperation class each process in synchronization method. i'm using dependencies data being imported/synchronized has several dependent relationships.

then add operations nsoperationqueue , let run.

there 2 additional important elements:

  1. when generate operations execute create new uuid nsstring, represents synchronization id. used track entities in core data have been synchronized, therefore, every entity has attribute stores synchronization id. used during synchronization process , accesses each method passed nsinvocationoperation.

  2. the import , synchronization methods actual methods access core data. inside each of methods create new instance of nsmanagedobjectcontext follows:

    phappdelegate *appdelegate = [[uiapplication sharedapplication] delegate]; nsmanagedobjectcontext *privatecontext = [[nsmanagedobjectcontext alloc] initwithconcurrencytype:nsprivatequeueconcurrencytype]; [privatecontext setparentcontext:[appdelegate mainmanagedobjectcontext]]; 

    using nsprivatequeueconcurrencytype opposed nsmainqueueconcurrencytype used in appdelegate main moc. create parent/child relationship using moc main thread , that's that. when saving child moc, understand changes propagate main moc , store (sqlite).

i'm new concurrency in ios , used guide me: http://code.tutsplus.com/tutorials/core-data-from-scratch-concurrency--cms-22131 (see strategy #2). different article , many other sources i've seen, not subclass nsoperation. instead, approach uses nsinvocationoperation in order pass each method want run concurrently.

my question: can take @ code , see if find i'm doing wrong or think work? far, i've had no problems running code. concurrency tough debug, before ship code, i'd have more experienced eyes on this.

thanks in advance!

synchronization class code on pastebin.com: http://pastebin.com/cuzww4tv (not in code paste, should enough evaluate process, let me know if need more)


Comments

Post a Comment

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -