I have an old code (mostly written in 2014-2015), and I need to update it as painless as possible.
First part:
NSManagedObjectContext *parentContext = [NSManagedObjectContext MR_contextForCurrentThread];
NSManagedObjectContext *context = [NSManagedObjectContext MR_contextWithParent:parentContext];
it says:
'MR_contextForCurrentThread' is deprecated: This method will be removed in MagicalRecord 3.0
I was trying to implement solutions from the internet, but none of it helped me.
Second part:
(IBAction)addButtonAction:(id)sender {
NSString *title = @"";
AppActionSheet *actionSheet = [AppActionSheet actionSheet];
[actionSheet setButtonWithTitle:AppLocalizedString(@"eventsCreateMenuCreateEvent") block:^{
[self actionSheetCreateNewEventDidSelected];
}];
[actionSheet showInView:self.view];
}
- (void)actionSheetCreateNewEventDidSelected {
NSManagedObjectContext *context = [NSManagedObjectContext MR_context];
AppEvent *event = [AppEvent MR_createEntityInContext:context];
AppContact *contact = [[AppUserSettings shared] authorizedUserInContext:context];
[event.participantsSet addObject:contact];
[event.activeParticipantsSet addObject:contact];
event.owner = contact;
event.modificationDate = [NSDate date];
AppEventContact *item = [AppEventContact MR_createEntityInContext:context];
item.contact = contact;
item.event = event;
item.index = @0;
AppAddEventViewController *addEventVC = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]
instantiateViewControllerWithIdentifier:@"AppAddEventViewController"];
addEventVC.delegate = self;
addEventVC.context = context;
addEventVC.event = event;
[self.navigationController pushViewController:addEventVC animated:YES];
}
The AddButton opens list of buttons, and one from the list is supposed to open view CreateNewEvent.
While debugging, when I press CreateEvent it stops on 4th string but doesn't forward to [self actionSheetCreateNewEventDidSelected];
And third one and the last:
[managedContext lock];
[managedContext reset];
//delete the store from the current managedObjectContext
if ([[managedContext persistentStoreCoordinator] removePersistentStore:[[[managedContext persistentStoreCoordinator] persistentStores] lastObject] error:&error]) {
// remove the file containing the data
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error];
//recreate the store like in the appDelegate method
[[managedContext persistentStoreCoordinator] addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeURL
options:nil
error:&error];
}
[managedContext unlock];
which complains at lock and unlock, but it would be incorrect to simply delete these two strings (anyways theyre not working anymore, and app seems to be working)?
I'm considering to rewrite everything to swift, but hope theres way to fix it for now. And thanks in advance!