From e58b9ef34fb341a28f3f6ca7327b430e2eef54cb Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Thu, 3 Sep 2020 13:56:46 -0400 Subject: [PATCH] Fetch request syntax update. --- platform-darwin/Source/MPAlgorithmV0.m | 2 +- platform-darwin/Source/MPAppDelegate_Store.m | 8 ++++---- platform-darwin/Source/Mac/MPMacAppDelegate.m | 2 +- platform-darwin/Source/Mac/MPSitesWindowController.m | 2 +- platform-darwin/Source/iOS/MPUsersViewController.m | 2 +- platform-darwin/Source/iOS/MPiOSAppDelegate.m | 3 +-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/platform-darwin/Source/MPAlgorithmV0.m b/platform-darwin/Source/MPAlgorithmV0.m index f984322b..e9279f11 100644 --- a/platform-darwin/Source/MPAlgorithmV0.m +++ b/platform-darwin/Source/MPAlgorithmV0.m @@ -88,7 +88,7 @@ static NSOperationQueue *_mpwQueue = nil; - (BOOL)tryMigrateUser:(MPUserEntity *)user inContext:(NSManagedObjectContext *)moc { NSError *error = nil; - NSFetchRequest *migrationRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPSiteEntity class] )]; + NSFetchRequest *migrationRequest = [MPSiteEntity fetchRequest]; migrationRequest.predicate = [NSPredicate predicateWithFormat:@"version_ < %d AND user == %@", self.version, user]; NSArray *migrationSites = [moc executeFetchRequest:migrationRequest error:&error]; if (!migrationSites) { diff --git a/platform-darwin/Source/MPAppDelegate_Store.m b/platform-darwin/Source/MPAppDelegate_Store.m index 2f880df5..a2853e9d 100644 --- a/platform-darwin/Source/MPAppDelegate_Store.m +++ b/platform-darwin/Source/MPAppDelegate_Store.m @@ -623,7 +623,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); // Find an existing user to update. NSError *error = nil; - NSFetchRequest *userFetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPUserEntity class] )]; + NSFetchRequest *userFetchRequest = [MPUserEntity fetchRequest]; userFetchRequest.predicate = [NSPredicate predicateWithFormat:@"name == %@", @(importUser->fullName)]; NSArray *users = [context executeFetchRequest:userFetchRequest error:&error]; if (!users) @@ -661,7 +661,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); MPMarshalledSite *importSite = &importUser->sites[s]; // Find an existing site to update. - NSFetchRequest *siteFetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPSiteEntity class] )]; + NSFetchRequest *siteFetchRequest = [MPSiteEntity fetchRequest]; siteFetchRequest.predicate = [NSPredicate predicateWithFormat:@"name == %@ AND user == %@", @(importSite->siteName), user]; NSArray *existingSites = [context executeFetchRequest:siteFetchRequest error:&error]; if (!existingSites) @@ -735,9 +735,9 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted ); return nil; } - for (NSString *feature in @[MPProductGenerateLogins, MPProductGenerateAnswers, MPProductOSIntegration, MPProductTouchID]) + for (NSString *feature in @[ MPProductGenerateLogins, MPProductGenerateAnswers, MPProductOSIntegration, MPProductTouchID ]) if ([[MPAppDelegate_Shared get] isFeatureUnlocked:feature]) - mpw_marshal_data_set_str( digest( strf( @"%@/%@", user.name, feature )).UTF8String, exportFile->data, + mpw_marshal_data_set_str( digest( strf( @"%@/%@", user.name, feature ) ).UTF8String, exportFile->data, "user", "_ext_mpw", feature.UTF8String, nil ); MPKey *key = [[MPKey alloc] initForFullName:user.name withMasterPassword:masterPassword]; diff --git a/platform-darwin/Source/Mac/MPMacAppDelegate.m b/platform-darwin/Source/Mac/MPMacAppDelegate.m index ff17f5ea..a74e0d23 100644 --- a/platform-darwin/Source/Mac/MPMacAppDelegate.m +++ b/platform-darwin/Source/Mac/MPMacAppDelegate.m @@ -646,7 +646,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven self.deleteUserItem.toolTip = mainActiveUser? nil: @"First select the user to delete."; NSError *error = nil; - NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPUserEntity class] )]; + NSFetchRequest *fetchRequest = [MPUserEntity fetchRequest]; fetchRequest.sortDescriptors = @[ [NSSortDescriptor sortDescriptorWithKey:@"lastUsed" ascending:NO] ]; NSArray *users = [mainContext executeFetchRequest:fetchRequest error:&error]; if (!users) diff --git a/platform-darwin/Source/Mac/MPSitesWindowController.m b/platform-darwin/Source/Mac/MPSitesWindowController.m index 9cab51c1..0ff59faf 100644 --- a/platform-darwin/Source/Mac/MPSitesWindowController.m +++ b/platform-darwin/Source/Mac/MPSitesWindowController.m @@ -628,7 +628,7 @@ [MPMacAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) { prof_rewind( @"moc" ); - NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPSiteEntity class] )]; + NSFetchRequest *fetchRequest = [MPSiteEntity fetchRequest]; fetchRequest.sortDescriptors = @[ [[NSSortDescriptor alloc] initWithKey:@"lastUsed" ascending:NO] ]; fetchRequest.predicate = [NSPredicate predicateWithFormat:@"name LIKE[cd] %@ AND user == %@", queryPattern, [MPMacAppDelegate get].activeUserOID]; diff --git a/platform-darwin/Source/iOS/MPUsersViewController.m b/platform-darwin/Source/iOS/MPUsersViewController.m index 4456867b..b0a31ad0 100644 --- a/platform-darwin/Source/iOS/MPUsersViewController.m +++ b/platform-darwin/Source/iOS/MPUsersViewController.m @@ -696,7 +696,7 @@ referenceSizeForFooterInSection:(NSInteger)section { [self afterUpdatesMainQueue:^{ if (![MPiOSAppDelegate managedObjectContextForMainThreadPerformBlockAndWait:^(NSManagedObjectContext *mainContext) { - NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPUserEntity class] )]; + NSFetchRequest *fetchRequest = [MPUserEntity fetchRequest]; fetchRequest.sortDescriptors = @[ [NSSortDescriptor sortDescriptorWithKey:NSStringFromSelector( @selector( lastUsed ) ) ascending:NO] ]; diff --git a/platform-darwin/Source/iOS/MPiOSAppDelegate.m b/platform-darwin/Source/iOS/MPiOSAppDelegate.m index d9348ae2..aab665f9 100644 --- a/platform-darwin/Source/iOS/MPiOSAppDelegate.m +++ b/platform-darwin/Source/iOS/MPiOSAppDelegate.m @@ -475,8 +475,7 @@ MP_LIBS_END for (NSURLQueryItem *item in [NSURLComponents componentsWithString:[url absoluteString]].queryItems) if ([item.name isEqualToString:@"fullName"]) { [MPiOSAppDelegate managedObjectContextPerformBlock:^(NSManagedObjectContext *context) { - NSFetchRequest - *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPUserEntity class] )]; + NSFetchRequest *fetchRequest = [MPUserEntity fetchRequest]; fetchRequest.predicate = [NSPredicate predicateWithFormat:@"name == %@", item.value]; NSArray *users = [context executeFetchRequest:fetchRequest error:nil]; [self migrateFor:users.firstObject];