Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


core data and threads grand central dispatch


core data and threads grand central dispatch  using -'iphone,ios,multithreading,core-data,grand-central-dispatch'

I'm a beginner with Grand Central Dispatch (GCD) and Core Data, and I need your help to use Core Data with CGD, so that the UI is not locked while I add 40.000 records to Core Data.

I know that CD is not thread safe, so I have to use another context, and then save the data and merge contexts, as far as I was able to understand from some articles.

What I couldn't do yet, is put the pieces together.

So, in my code, I need your help on how to to that.

I have:

/*some other code*/

for (NSDictionary *memberData in arrayWithResult) {

    //get the Activities for this member
    NSArray *arrayWithMemberActivities = [activitiesDict objectForKey:[memberData objectForKey:@"MemberID"]];

    //create the Member, with the NSSet of Activities
    [Members createMemberWithDataFromServer:memberData
                         andActivitiesArray:arrayWithMemberActivities
                              andStaffArray:nil
                           andContactsArray:nil
                     inManagedObjectContext:self.managedObjectContext];
}


How can I transform this to work on the background, and then, when done saving, save the data and update the UI, without blocking the UI while saving the 40.000 objects?
    

asked Oct 7, 2015 by deepak gupta
0 votes
1 view



Related Hot Questions



Government Jobs Opening


...