Search code examples
ioscore-dataicloudmagicalrecord

iCloud low speed to retrieve data


I use Core Date and iCloud in my app, but the speed for retrieving data is too low. To create the Core Data stack, I've used MagicalRecords method

[MagicalRecord setupCoreDataStackWithiCloudContainer:nil localStoreNamed:@"base"];

Can I retrieve data not in the main thread? The loading takes a lot of time.


Solution

  • Just use GCD.

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [MagicalRecord setupCoreDataStackWithiCloudContainer:nil 
                                             localStoreNamed:@"base"];
    
        dispatch_async(dispatch_get_main_queue(), ^{
              // update your UI if necessary
        });
    });