Build error when replacing deprecated MagicalRecord methods in FTASync

195 views Asked by At

I'm trying to get FTASync working for my iPad app. This is the FTASync code that's giving me a build error and I don't know what's wrong with it. I had to replace a deprecated statement:

[MagicalRecord saveInBackgroundWithBlock:^(localContext)

with the following (first statement; the remainder is original FTASync code)

    [localContext MR_saveToPersistentStoreWithCompletion:^(BOOL success, NSError *error){

    [self syncAll];
}

      completion:^{
          if (self.progressBlock)
              self.progressBlock(1.0, @"Complete");

          if (![NSThread isMainThread]) {
              FSALog(@"%@", @"Completion block must be called on main thread");
          }

          //Use this notification and user defaults key to update an "Last Updated" message in the UI
          [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"FTASyncLastSyncDate"];
          [[NSUserDefaults standardUserDefaults] synchronize];
          dispatch_async(dispatch_get_main_queue(), ^{
              [[NSNotificationCenter defaultCenter] postNotificationName:@"FTASyncDidSync" object:nil];
          });

          if (completion)
              completion();

          self.syncInProgress = NO;
          self.progressBlock = nil;
          self.progress = 0;

          //End background task
          if ([[UIDevice currentDevice] isMultitaskingSupported]) {
              FSCLog(@"Completed sync.");
              [[UIApplication sharedApplication] endBackgroundTask:bgTask];
              bgTask = UIBackgroundTaskInvalid;
          }
      }];

This is the definition of completion:

typedef void (^FTACompletionBlock)(void);

This is the build error I'm getting, which is probably caused by a syntax error somewhere, but I don't see it:

No visible @interface for 'NSManagedObjectContext' declares the selector 'MR_saveToPersistentStoreWithCompletion:completion:'

Can someone tell me what is causing this? and how to fix it?

0

There are 0 answers