objective c - NSPrivateQueueConcurrencyType Not saving properly -



objective c - NSPrivateQueueConcurrencyType Not saving properly -

the next method gets called in order populate core-data after afnetworking fetches info app server.

the info seems working when table updated can see new info beingness updated in uitableview.

now problem have tho can see info ( after has been fetches server, stored core-data , refetches display in uitableview) if go , close app , re open it, info not there anymore.

it seems if info not persistent , problem seems thread. given if remove thread alternative in method works fine.

what missing?? have tried things came across can't seem find solution.

nsmanagedobjectcontext *childcontext = [[nsmanagedobjectcontext alloc] initwithconcurrencytype:nsprivatequeueconcurrencytype]; childcontext.parentcontext = managedobjectcontext; mymodel.context = childcontext; [childcontext performblock:^{ // ... lots controller logic code calls class mymodel core-data save methods // sort wall pictures if ( [dataholder[@"verb"] isequaltostring:@"addwallpicture"] ) { info = @{ @"resourceid":dataholder[@"_id"][@"$id"], @"resourcename":dataholder[@"details"][@"resourcename"], @"author":@{ @"id":dataholder[@"userid"][@"$id"], @"username":dataholder[@"details"][@"authorname"] }, @"likesnumber":@0, @"likespeople":@[] }; [mymodel savesocialwall:data date:date verb:dataholder[@"verb"] code:dataholder[@"_id"][@"$id"] myuser:myuser]; continue; } [childcontext save:&error]; }];

you have save main context @ point, e.g. after saving kid context.

saving kid context saves main context, , saving main context saves store file.

like (written on phone, there syntax errors):

// ... [childcontext save:&error]; [maincontext performblock:^{ [maincontext save:&error]; }];

in swift 2.0 be:

do { seek childcontext.save() maincontext.performblock { { seek maincontext.save() } grab allow err nserror { print("could not save main context: \(err.localizeddescription)") } } } grab allow err nserror { print("could not save private context: \(err.localizeddescription)") }

objective-c cocoa-touch cocoa core-data nsmanagedobject

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -