From fa57d08ffed09a5f5d3a89f0427b6e728d849ca9 Mon Sep 17 00:00:00 2001 From: Philipp Kinschel Date: Mon, 26 Aug 2013 12:37:48 -0700 Subject: [PATCH 01/40] Editable NSSearchPathDirectory for SQL file location --- PSCCoreDataStack/PSCCoreDataStack.h | 2 ++ PSCCoreDataStack/PSCCoreDataStack.m | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/PSCCoreDataStack/PSCCoreDataStack.h b/PSCCoreDataStack/PSCCoreDataStack.h index c726ae9..b8eef12 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.h +++ b/PSCCoreDataStack/PSCCoreDataStack.h @@ -19,6 +19,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName + searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory type:(NSString *)storeType configuration:(NSString *)configuration options:(NSDictionary *)options @@ -27,6 +28,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName + searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock; + (void)saveAndPersistContextBlocking:(BOOL)wait; diff --git a/PSCCoreDataStack/PSCCoreDataStack.m b/PSCCoreDataStack/PSCCoreDataStack.m index 72012ea..7782a60 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.m +++ b/PSCCoreDataStack/PSCCoreDataStack.m @@ -22,48 +22,49 @@ @implementation PSCCoreDataStack + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName + searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory type:(NSString *)storeType configuration:(NSString *)configuration options:(NSDictionary *)options success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { - + NSParameterAssert(modelURL != nil); NSParameterAssert([storeType isEqualToString:NSSQLiteStoreType] || [storeType isEqualToString:NSBinaryStoreType] || [storeType isEqualToString:NSInMemoryStoreType]); if (![storeType isEqualToString:NSInMemoryStoreType]) { NSParameterAssert(storeFileName != nil); } - + NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; NSAssert(model != nil, @"Failed to initialize model with URL: %@", modelURL); - + NSPersistentStoreCoordinator *persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; NSAssert(persistentStoreCoordinator != nil, @"Failed to initialize persistent store coordinator with model: %@", model); - + psc_privateContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; psc_privateContext.persistentStoreCoordinator = persistentStoreCoordinator; - + psc_mainContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; psc_mainContext.parentContext = psc_privateContext; - + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSURL *storeURL = nil; - + if (storeFileName != nil) { storeURL = [[[NSFileManager new] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; storeURL = [storeURL URLByAppendingPathComponent:storeFileName]; } - + NSError *error = nil; NSPersistentStore *store = [persistentStoreCoordinator addPersistentStoreWithType:storeType configuration:configuration URL:storeURL options:options error:&error]; - + if (store == nil) { PSCCDLog(@"Error adding persistent store to coordinator %@\n%@", [error localizedDescription], [error userInfo]); - + if (errorBlock != nil) { dispatch_async(dispatch_get_main_queue(), ^{ errorBlock(error); @@ -77,11 +78,12 @@ + (void)setupWithModelURL:(NSURL *)modelURL }); } -+ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { ++ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption: @(YES), NSInferMappingModelAutomaticallyOption: @(YES)}; - + [self setupWithModelURL:modelURL storeFileName:storeFileName + searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory type:NSSQLiteStoreType configuration:nil options:options From f993588309867655ed459f0bd5f959918ace4d6a Mon Sep 17 00:00:00 2001 From: Philipp Kinschel Date: Tue, 27 Aug 2013 17:09:54 -0700 Subject: [PATCH 02/40] optional filePathURL for SQL file --- PSCCoreDataStack/PSCCoreDataStack.h | 4 ++-- PSCCoreDataStack/PSCCoreDataStack.m | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/PSCCoreDataStack/PSCCoreDataStack.h b/PSCCoreDataStack/PSCCoreDataStack.h index b8eef12..e1ab968 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.h +++ b/PSCCoreDataStack/PSCCoreDataStack.h @@ -19,7 +19,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName - searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory + storeFilePathURL:(NSURL *)storeFilePathURL type:(NSString *)storeType configuration:(NSString *)configuration options:(NSDictionary *)options @@ -28,7 +28,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName - searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory + storeFilePathURL:(NSURL *)storeFilePathURL success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock; + (void)saveAndPersistContextBlocking:(BOOL)wait; diff --git a/PSCCoreDataStack/PSCCoreDataStack.m b/PSCCoreDataStack/PSCCoreDataStack.m index 7782a60..7875c1d 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.m +++ b/PSCCoreDataStack/PSCCoreDataStack.m @@ -22,7 +22,7 @@ @implementation PSCCoreDataStack + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName - searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory + storeFilePathURL:(NSURL *)storeFilePathURL type:(NSString *)storeType configuration:(NSString *)configuration options:(NSDictionary *)options @@ -51,7 +51,14 @@ + (void)setupWithModelURL:(NSURL *)modelURL NSURL *storeURL = nil; if (storeFileName != nil) { - storeURL = [[[NSFileManager new] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; + + if (storeFilePathURL == nil) { + storeURL = [[[NSFileManager new] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; + } + else { + storeURL = storeFilePathURL; + } + storeURL = [storeURL URLByAppendingPathComponent:storeFileName]; } @@ -78,12 +85,12 @@ + (void)setupWithModelURL:(NSURL *)modelURL }); } -+ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { ++ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName storeFilePathURL:(NSURL *)storeFilePathURL success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption: @(YES), NSInferMappingModelAutomaticallyOption: @(YES)}; [self setupWithModelURL:modelURL storeFileName:storeFileName - searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory + storeFilePathURL:(NSURL *)storeFilePathURL type:NSSQLiteStoreType configuration:nil options:options From 24202286e2d770ce2f04ed2f9b1b6e2b9103229c Mon Sep 17 00:00:00 2001 From: Philipp Kinschel Date: Wed, 12 Feb 2014 12:10:13 -0800 Subject: [PATCH 03/40] Revert "optional filePathURL for SQL file" This reverts commit f993588309867655ed459f0bd5f959918ace4d6a. --- PSCCoreDataStack/PSCCoreDataStack.h | 4 ++-- PSCCoreDataStack/PSCCoreDataStack.m | 15 ++++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/PSCCoreDataStack/PSCCoreDataStack.h b/PSCCoreDataStack/PSCCoreDataStack.h index e1ab968..b8eef12 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.h +++ b/PSCCoreDataStack/PSCCoreDataStack.h @@ -19,7 +19,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName - storeFilePathURL:(NSURL *)storeFilePathURL + searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory type:(NSString *)storeType configuration:(NSString *)configuration options:(NSDictionary *)options @@ -28,7 +28,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName - storeFilePathURL:(NSURL *)storeFilePathURL + searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock; + (void)saveAndPersistContextBlocking:(BOOL)wait; diff --git a/PSCCoreDataStack/PSCCoreDataStack.m b/PSCCoreDataStack/PSCCoreDataStack.m index 7875c1d..7782a60 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.m +++ b/PSCCoreDataStack/PSCCoreDataStack.m @@ -22,7 +22,7 @@ @implementation PSCCoreDataStack + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName - storeFilePathURL:(NSURL *)storeFilePathURL + searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory type:(NSString *)storeType configuration:(NSString *)configuration options:(NSDictionary *)options @@ -51,14 +51,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL NSURL *storeURL = nil; if (storeFileName != nil) { - - if (storeFilePathURL == nil) { - storeURL = [[[NSFileManager new] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; - } - else { - storeURL = storeFilePathURL; - } - + storeURL = [[[NSFileManager new] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; storeURL = [storeURL URLByAppendingPathComponent:storeFileName]; } @@ -85,12 +78,12 @@ + (void)setupWithModelURL:(NSURL *)modelURL }); } -+ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName storeFilePathURL:(NSURL *)storeFilePathURL success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { ++ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption: @(YES), NSInferMappingModelAutomaticallyOption: @(YES)}; [self setupWithModelURL:modelURL storeFileName:storeFileName - storeFilePathURL:(NSURL *)storeFilePathURL + searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory type:NSSQLiteStoreType configuration:nil options:options From deb3ee8f0cdb39b93b8a1ef2c7aa7eb42dca7153 Mon Sep 17 00:00:00 2001 From: Philipp Kinschel Date: Wed, 12 Feb 2014 12:10:31 -0800 Subject: [PATCH 04/40] Revert "Editable NSSearchPathDirectory for SQL file location" This reverts commit fa57d08ffed09a5f5d3a89f0427b6e728d849ca9. --- PSCCoreDataStack/PSCCoreDataStack.h | 2 -- PSCCoreDataStack/PSCCoreDataStack.m | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/PSCCoreDataStack/PSCCoreDataStack.h b/PSCCoreDataStack/PSCCoreDataStack.h index b8eef12..c726ae9 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.h +++ b/PSCCoreDataStack/PSCCoreDataStack.h @@ -19,7 +19,6 @@ + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName - searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory type:(NSString *)storeType configuration:(NSString *)configuration options:(NSDictionary *)options @@ -28,7 +27,6 @@ + (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName - searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock; + (void)saveAndPersistContextBlocking:(BOOL)wait; diff --git a/PSCCoreDataStack/PSCCoreDataStack.m b/PSCCoreDataStack/PSCCoreDataStack.m index 7782a60..72012ea 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.m +++ b/PSCCoreDataStack/PSCCoreDataStack.m @@ -22,49 +22,48 @@ @implementation PSCCoreDataStack + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName - searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory type:(NSString *)storeType configuration:(NSString *)configuration options:(NSDictionary *)options success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { - + NSParameterAssert(modelURL != nil); NSParameterAssert([storeType isEqualToString:NSSQLiteStoreType] || [storeType isEqualToString:NSBinaryStoreType] || [storeType isEqualToString:NSInMemoryStoreType]); if (![storeType isEqualToString:NSInMemoryStoreType]) { NSParameterAssert(storeFileName != nil); } - + NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; NSAssert(model != nil, @"Failed to initialize model with URL: %@", modelURL); - + NSPersistentStoreCoordinator *persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; NSAssert(persistentStoreCoordinator != nil, @"Failed to initialize persistent store coordinator with model: %@", model); - + psc_privateContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; psc_privateContext.persistentStoreCoordinator = persistentStoreCoordinator; - + psc_mainContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; psc_mainContext.parentContext = psc_privateContext; - + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSURL *storeURL = nil; - + if (storeFileName != nil) { storeURL = [[[NSFileManager new] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; storeURL = [storeURL URLByAppendingPathComponent:storeFileName]; } - + NSError *error = nil; NSPersistentStore *store = [persistentStoreCoordinator addPersistentStoreWithType:storeType configuration:configuration URL:storeURL options:options error:&error]; - + if (store == nil) { PSCCDLog(@"Error adding persistent store to coordinator %@\n%@", [error localizedDescription], [error userInfo]); - + if (errorBlock != nil) { dispatch_async(dispatch_get_main_queue(), ^{ errorBlock(error); @@ -78,12 +77,11 @@ + (void)setupWithModelURL:(NSURL *)modelURL }); } -+ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { ++ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption: @(YES), NSInferMappingModelAutomaticallyOption: @(YES)}; - + [self setupWithModelURL:modelURL storeFileName:storeFileName - searchPathDirectory:(NSSearchPathDirectory)searchPathDirectory type:NSSQLiteStoreType configuration:nil options:options From 1bbac692b0ce677b1331ab894f83cd1b82ad0fd6 Mon Sep 17 00:00:00 2001 From: Philipp Kinschel Date: Mon, 17 Feb 2014 16:27:54 -0800 Subject: [PATCH 05/40] optinal store URL, store migration with setStoreURL --- PSCCoreDataStack/PSCCoreDataStack.h | 3 ++ PSCCoreDataStack/PSCCoreDataStack.m | 80 +++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 17 deletions(-) diff --git a/PSCCoreDataStack/PSCCoreDataStack.h b/PSCCoreDataStack/PSCCoreDataStack.h index c726ae9..e33942d 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.h +++ b/PSCCoreDataStack/PSCCoreDataStack.h @@ -20,6 +20,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName type:(NSString *)storeType + storeURL:(NSURL *)storeURL configuration:(NSString *)configuration options:(NSDictionary *)options success:(void(^)())successBlock @@ -38,4 +39,6 @@ autoMigratedSQLiteStoreFileName:(NSString *)storeFileName + (NSManagedObjectContext *)mainContext; + (NSManagedObjectContext *)newChildContextWithPrivateQueue; ++ (void)setStoreURL:(NSURL *)storeURL; + @end diff --git a/PSCCoreDataStack/PSCCoreDataStack.m b/PSCCoreDataStack/PSCCoreDataStack.m index 72012ea..22499f6 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.m +++ b/PSCCoreDataStack/PSCCoreDataStack.m @@ -23,47 +23,51 @@ @implementation PSCCoreDataStack + (void)setupWithModelURL:(NSURL *)modelURL storeFileName:(NSString *)storeFileName type:(NSString *)storeType + storeURL:(NSURL *)storeURL configuration:(NSString *)configuration options:(NSDictionary *)options success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { - + NSParameterAssert(modelURL != nil); NSParameterAssert([storeType isEqualToString:NSSQLiteStoreType] || [storeType isEqualToString:NSBinaryStoreType] || [storeType isEqualToString:NSInMemoryStoreType]); if (![storeType isEqualToString:NSInMemoryStoreType]) { - NSParameterAssert(storeFileName != nil); + NSParameterAssert((storeFileName != nil) != (storeURL != nil)); } - + NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL]; NSAssert(model != nil, @"Failed to initialize model with URL: %@", modelURL); - + NSPersistentStoreCoordinator *persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model]; NSAssert(persistentStoreCoordinator != nil, @"Failed to initialize persistent store coordinator with model: %@", model); - + psc_privateContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; psc_privateContext.persistentStoreCoordinator = persistentStoreCoordinator; - + psc_mainContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType]; psc_mainContext.parentContext = psc_privateContext; - + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSURL *storeURL = nil; - - if (storeFileName != nil) { - storeURL = [[[NSFileManager new] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; - storeURL = [storeURL URLByAppendingPathComponent:storeFileName]; + __block NSURL *url = storeURL; + + if (url == nil) { + url = [[[NSFileManager new] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject]; + + if(storeFileName != nil) { + url = [url URLByAppendingPathComponent:storeFileName]; + } } - + NSError *error = nil; NSPersistentStore *store = [persistentStoreCoordinator addPersistentStoreWithType:storeType configuration:configuration - URL:storeURL + URL:url options:options error:&error]; - + if (store == nil) { PSCCDLog(@"Error adding persistent store to coordinator %@\n%@", [error localizedDescription], [error userInfo]); - + if (errorBlock != nil) { dispatch_async(dispatch_get_main_queue(), ^{ errorBlock(error); @@ -79,10 +83,11 @@ + (void)setupWithModelURL:(NSURL *)modelURL + (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption: @(YES), NSInferMappingModelAutomaticallyOption: @(YES)}; - + [self setupWithModelURL:modelURL storeFileName:storeFileName type:NSSQLiteStoreType + storeURL:nil configuration:nil options:options success:successBlock @@ -128,4 +133,45 @@ + (NSManagedObjectContext *)newChildContextWithPrivateQueue { return [[self mainContext] newChildContextWithConcurrencyType:NSPrivateQueueConcurrencyType]; } ++ (void)setStoreURL:(NSURL *)storeURL { + NSPersistentStoreCoordinator *storeCoordinator = psc_privateContext.persistentStoreCoordinator; + NSArray *stores = storeCoordinator.persistentStores; + + NSAssert([stores count] == 1, @"PSCCoreDataStack doesn't support changing storeURL for multiple Stores"); + + NSPersistentStore *store = stores[0]; + + if (![store.URL isEqual:storeURL]) { + NSError *error; + NSPersistentStore *newPersistanceStore = [psc_privateContext.persistentStoreCoordinator migratePersistentStore:store toURL:storeURL options:nil withType:store.type error:&error]; + + if (newPersistanceStore) { + NSFileManager *fileManager = [NSFileManager defaultManager]; + + if ([fileManager fileExistsAtPath:[store.URL path]]) { + [fileManager removeItemAtURL:store.URL error:&error]; + } + + NSURL *shm = [[store.URL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-shm"]; + if ([fileManager fileExistsAtPath:[shm path]]) { + NSURL *newSHM = [[storeURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-shm"]; + + [fileManager moveItemAtURL:shm toURL:newSHM error:&error]; + } + + NSURL *wal = [[store.URL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-wal"]; + if ([fileManager fileExistsAtPath:[wal path]]) { + NSURL *newWAL = [[storeURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-wal"]; + + [fileManager moveItemAtURL:wal toURL:newWAL error:&error]; + } + else { + NSLog(@"%@ %@", [error localizedDescription], [error userInfo]); + + abort(); + } + } + } +} + @end From 38b60c57eddab245831cd479f94d1bf612e0cfc2 Mon Sep 17 00:00:00 2001 From: Philipp Kinschel Date: Thu, 20 Feb 2014 14:12:18 -0800 Subject: [PATCH 06/40] cleaned up migration code. Removing WAL files after migration --- PSCCoreDataStack/PSCCoreDataStack.h | 2 +- PSCCoreDataStack/PSCCoreDataStack.m | 49 +++++++++++++---------------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/PSCCoreDataStack/PSCCoreDataStack.h b/PSCCoreDataStack/PSCCoreDataStack.h index e33942d..f6e1ac9 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.h +++ b/PSCCoreDataStack/PSCCoreDataStack.h @@ -39,6 +39,6 @@ autoMigratedSQLiteStoreFileName:(NSString *)storeFileName + (NSManagedObjectContext *)mainContext; + (NSManagedObjectContext *)newChildContextWithPrivateQueue; -+ (void)setStoreURL:(NSURL *)storeURL; ++ (void)migratePersistentStoreToURL:(NSURL *)storeURL; @end diff --git a/PSCCoreDataStack/PSCCoreDataStack.m b/PSCCoreDataStack/PSCCoreDataStack.m index 22499f6..2e1e0f9 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.m +++ b/PSCCoreDataStack/PSCCoreDataStack.m @@ -133,7 +133,11 @@ + (NSManagedObjectContext *)newChildContextWithPrivateQueue { return [[self mainContext] newChildContextWithConcurrencyType:NSPrivateQueueConcurrencyType]; } -+ (void)setStoreURL:(NSURL *)storeURL { +//////////////////////////////////////////////////////////////////////// +#pragma mark - Migration +//////////////////////////////////////////////////////////////////////// + ++ (void)migratePersistentStoreToURL:(NSURL *)storeURL { NSPersistentStoreCoordinator *storeCoordinator = psc_privateContext.persistentStoreCoordinator; NSArray *stores = storeCoordinator.persistentStores; @@ -143,33 +147,24 @@ + (void)setStoreURL:(NSURL *)storeURL { if (![store.URL isEqual:storeURL]) { NSError *error; - NSPersistentStore *newPersistanceStore = [psc_privateContext.persistentStoreCoordinator migratePersistentStore:store toURL:storeURL options:nil withType:store.type error:&error]; + [psc_privateContext.persistentStoreCoordinator migratePersistentStore:store toURL:storeURL options:nil withType:store.type error:&error]; - if (newPersistanceStore) { - NSFileManager *fileManager = [NSFileManager defaultManager]; - - if ([fileManager fileExistsAtPath:[store.URL path]]) { - [fileManager removeItemAtURL:store.URL error:&error]; - } - - NSURL *shm = [[store.URL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-shm"]; - if ([fileManager fileExistsAtPath:[shm path]]) { - NSURL *newSHM = [[storeURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-shm"]; - - [fileManager moveItemAtURL:shm toURL:newSHM error:&error]; - } - - NSURL *wal = [[store.URL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-wal"]; - if ([fileManager fileExistsAtPath:[wal path]]) { - NSURL *newWAL = [[storeURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-wal"]; - - [fileManager moveItemAtURL:wal toURL:newWAL error:&error]; - } - else { - NSLog(@"%@ %@", [error localizedDescription], [error userInfo]); - - abort(); - } + NSAssert(error == nil, @"Error migrating persistent store %@ %@\n%@", psc_privateContext, [error localizedDescription], [error userInfo]); + + NSFileManager *fileManager = [NSFileManager defaultManager]; + + if ([fileManager fileExistsAtPath:[store.URL path]]) { + [fileManager removeItemAtURL:store.URL error:&error]; + } + + NSURL *shm = [[store.URL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-shm"]; + if ([fileManager fileExistsAtPath:[shm path]]) { + [fileManager removeItemAtURL:shm error:&error]; + } + + NSURL *wal = [[store.URL URLByDeletingPathExtension] URLByAppendingPathExtension:@"sqlite-wal"]; + if ([fileManager fileExistsAtPath:[wal path]]) { + [fileManager removeItemAtURL:wal error:&error]; } } } From 484b98b8a5d55492944c068857e4319e9ee80c46 Mon Sep 17 00:00:00 2001 From: Philip Messlehner Date: Wed, 9 Apr 2014 15:54:15 +0200 Subject: [PATCH 07/40] fixed Warning regarding OCUnit --- PSCCoreDataStack.xcodeproj/project.pbxproj | 130 +-------------------- 1 file changed, 1 insertion(+), 129 deletions(-) diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index efef221..02a1c85 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -9,11 +9,6 @@ /* Begin PBXBuildFile section */ 9B17A9F617025C8300DEF0B9 /* PSCPersistenceOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B17A9F517025C8300DEF0B9 /* PSCPersistenceOperation.m */; }; 9B5FDB1A16FC65AB002FA5A6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB1916FC65AB002FA5A6 /* Foundation.framework */; }; - 9B5FDB2916FC65AC002FA5A6 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB2816FC65AC002FA5A6 /* SenTestingKit.framework */; }; - 9B5FDB2C16FC65AC002FA5A6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB1916FC65AB002FA5A6 /* Foundation.framework */; }; - 9B5FDB2F16FC65AC002FA5A6 /* libPSCCoreDataStack.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB1616FC65AB002FA5A6 /* libPSCCoreDataStack.a */; }; - 9B5FDB3516FC65AC002FA5A6 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9B5FDB3316FC65AC002FA5A6 /* InfoPlist.strings */; }; - 9B5FDB3816FC65AC002FA5A6 /* PSCCoreDataStackTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB3716FC65AC002FA5A6 /* PSCCoreDataStackTests.m */; }; 9B5FDB4916FC65DA002FA5A6 /* NSManagedObject+PSCCoreDataHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB4216FC65DA002FA5A6 /* NSManagedObject+PSCCoreDataHelper.m */; }; 9B5FDB4A16FC65DA002FA5A6 /* NSManagedObjectContext+PSCCoreDataHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB4416FC65DA002FA5A6 /* NSManagedObjectContext+PSCCoreDataHelper.m */; }; 9B5FDB4B16FC65DA002FA5A6 /* PSCContextWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB4616FC65DA002FA5A6 /* PSCContextWatcher.m */; }; @@ -23,16 +18,6 @@ 9B5FDB5B16FC7387002FA5A6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB5A16FC7387002FA5A6 /* UIKit.framework */; }; /* End PBXBuildFile section */ -/* Begin PBXContainerItemProxy section */ - 9B5FDB2D16FC65AC002FA5A6 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 9B5FDB0E16FC65AB002FA5A6 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 9B5FDB1516FC65AB002FA5A6; - remoteInfo = PSCCoreDataStack; - }; -/* End PBXContainerItemProxy section */ - /* Begin PBXCopyFilesBuildPhase section */ 9B5FDB1416FC65AB002FA5A6 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; @@ -51,7 +36,6 @@ 9B5FDB1616FC65AB002FA5A6 /* libPSCCoreDataStack.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPSCCoreDataStack.a; sourceTree = BUILT_PRODUCTS_DIR; }; 9B5FDB1916FC65AB002FA5A6 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 9B5FDB1D16FC65AB002FA5A6 /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; - 9B5FDB2716FC65AC002FA5A6 /* PSCCoreDataStackTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PSCCoreDataStackTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 9B5FDB2816FC65AC002FA5A6 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 9B5FDB3216FC65AC002FA5A6 /* PSCCoreDataStackTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PSCCoreDataStackTests-Info.plist"; sourceTree = ""; }; 9B5FDB3416FC65AC002FA5A6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; @@ -83,16 +67,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 9B5FDB2316FC65AC002FA5A6 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 9B5FDB2916FC65AC002FA5A6 /* SenTestingKit.framework in Frameworks */, - 9B5FDB2C16FC65AC002FA5A6 /* Foundation.framework in Frameworks */, - 9B5FDB2F16FC65AC002FA5A6 /* libPSCCoreDataStack.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -110,7 +84,6 @@ isa = PBXGroup; children = ( 9B5FDB1616FC65AB002FA5A6 /* libPSCCoreDataStack.a */, - 9B5FDB2716FC65AC002FA5A6 /* PSCCoreDataStackTests.octest */, ); name = Products; sourceTree = ""; @@ -194,31 +167,13 @@ productReference = 9B5FDB1616FC65AB002FA5A6 /* libPSCCoreDataStack.a */; productType = "com.apple.product-type.library.static"; }; - 9B5FDB2616FC65AC002FA5A6 /* PSCCoreDataStackTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 9B5FDB3E16FC65AC002FA5A6 /* Build configuration list for PBXNativeTarget "PSCCoreDataStackTests" */; - buildPhases = ( - 9B5FDB2216FC65AC002FA5A6 /* Sources */, - 9B5FDB2316FC65AC002FA5A6 /* Frameworks */, - 9B5FDB2416FC65AC002FA5A6 /* Resources */, - 9B5FDB2516FC65AC002FA5A6 /* ShellScript */, - ); - buildRules = ( - ); - dependencies = ( - 9B5FDB2E16FC65AC002FA5A6 /* PBXTargetDependency */, - ); - name = PSCCoreDataStackTests; - productName = PSCCoreDataStackTests; - productReference = 9B5FDB2716FC65AC002FA5A6 /* PSCCoreDataStackTests.octest */; - productType = "com.apple.product-type.bundle"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ 9B5FDB0E16FC65AB002FA5A6 /* Project object */ = { isa = PBXProject; attributes = { + LastTestingUpgradeCheck = 0510; LastUpgradeCheck = 0460; ORGANIZATIONNAME = PocketScience; }; @@ -235,38 +190,10 @@ projectRoot = ""; targets = ( 9B5FDB1516FC65AB002FA5A6 /* PSCCoreDataStack */, - 9B5FDB2616FC65AC002FA5A6 /* PSCCoreDataStackTests */, ); }; /* End PBXProject section */ -/* Begin PBXResourcesBuildPhase section */ - 9B5FDB2416FC65AC002FA5A6 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 9B5FDB3516FC65AC002FA5A6 /* InfoPlist.strings in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 9B5FDB2516FC65AC002FA5A6 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 9B5FDB1216FC65AB002FA5A6 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -281,24 +208,8 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 9B5FDB2216FC65AC002FA5A6 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 9B5FDB3816FC65AC002FA5A6 /* PSCCoreDataStackTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXTargetDependency section */ - 9B5FDB2E16FC65AC002FA5A6 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 9B5FDB1516FC65AB002FA5A6 /* PSCCoreDataStack */; - targetProxy = 9B5FDB2D16FC65AC002FA5A6 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - /* Begin PBXVariantGroup section */ 9B5FDB3316FC65AC002FA5A6 /* InfoPlist.strings */ = { isa = PBXVariantGroup; @@ -388,36 +299,6 @@ }; name = Release; }; - 9B5FDB3F16FC65AC002FA5A6 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "PSCCoreDataStack/PSCCoreDataStack-Prefix.pch"; - INFOPLIST_FILE = "PSCCoreDataStackTests/PSCCoreDataStackTests-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = octest; - }; - name = Debug; - }; - 9B5FDB4016FC65AC002FA5A6 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - ); - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "PSCCoreDataStack/PSCCoreDataStack-Prefix.pch"; - INFOPLIST_FILE = "PSCCoreDataStackTests/PSCCoreDataStackTests-Info.plist"; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = octest; - }; - name = Release; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -439,15 +320,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 9B5FDB3E16FC65AC002FA5A6 /* Build configuration list for PBXNativeTarget "PSCCoreDataStackTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 9B5FDB3F16FC65AC002FA5A6 /* Debug */, - 9B5FDB4016FC65AC002FA5A6 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; /* End XCConfigurationList section */ }; rootObject = 9B5FDB0E16FC65AB002FA5A6 /* Project object */; From e51a757d21c45dc636fe23cd60bf107c7186f8cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ju=CC=88rgen=20Falb?= Date: Mon, 8 Sep 2014 09:19:50 +0200 Subject: [PATCH 08/40] Added method to truncate/clear SQLite DB --- PSCCoreDataStack/PSCCoreDataStack.h | 2 ++ PSCCoreDataStack/PSCCoreDataStack.m | 42 +++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/PSCCoreDataStack/PSCCoreDataStack.h b/PSCCoreDataStack/PSCCoreDataStack.h index c726ae9..d3c05a0 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.h +++ b/PSCCoreDataStack/PSCCoreDataStack.h @@ -38,4 +38,6 @@ autoMigratedSQLiteStoreFileName:(NSString *)storeFileName + (NSManagedObjectContext *)mainContext; + (NSManagedObjectContext *)newChildContextWithPrivateQueue; ++ (BOOL)clearSQLiteDatabase:(NSManagedObjectContext *)context; + @end diff --git a/PSCCoreDataStack/PSCCoreDataStack.m b/PSCCoreDataStack/PSCCoreDataStack.m index b8de2d7..f27e4f1 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.m +++ b/PSCCoreDataStack/PSCCoreDataStack.m @@ -89,6 +89,48 @@ + (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSS error:errorBlock]; } ++ (BOOL)clearSQLiteDatabase:(NSManagedObjectContext *)context { + // find top most context with store coordinator + NSManagedObjectContext *topContext = context; + while (topContext.parentContext != nil) { + topContext = topContext.parentContext; + } + + NSError * error; + NSPersistentStoreCoordinator *persistentStoreCoordinator = [topContext persistentStoreCoordinator]; + NSPersistentStore *store = [[persistentStoreCoordinator persistentStores] lastObject]; + + // retrieve the store URL, configuration, and options + NSURL * storeURL = [persistentStoreCoordinator URLForPersistentStore:store]; + NSDictionary *options = [store options]; + NSString *configurationName = [store configurationName]; + + // lock the current context + [context lock]; + // reset all contexts + NSManagedObjectContext *curContext = context; + [curContext reset]; + while (curContext.parentContext != nil) { + curContext = curContext.parentContext; + [curContext reset]; + } + + // lock the current context + [topContext lock]; + //delete the store from the current managedObjectContext + BOOL result = [persistentStoreCoordinator removePersistentStore:store error:&error]; + if (result) { + // remove the file containing the data + [[NSFileManager defaultManager] removeItemAtURL:storeURL error:&error]; + //recreate the store like in the appDelegate method + [persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:configurationName URL:storeURL options:options error:&error]; //recreates the persistent store + } + [topContext unlock]; + [context unlock]; + + return result; +} + //////////////////////////////////////////////////////////////////////// #pragma mark - Saving //////////////////////////////////////////////////////////////////////// From c5af683bf0bd9f9a4df2508dd5ce11a236d74415 Mon Sep 17 00:00:00 2001 From: Robert Fischer Date: Fri, 5 Jun 2015 10:30:11 +0200 Subject: [PATCH 09/40] build for all archs --- PSCCoreDataStack.xcodeproj/project.pbxproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index 02a1c85..b281b67 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -247,7 +247,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.0; - ONLY_ACTIVE_ARCH = YES; + ONLY_ACTIVE_ARCH = NO; SDKROOT = iphoneos; }; name = Debug; @@ -270,6 +270,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 5.0; + ONLY_ACTIVE_ARCH = NO; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; From 0dd02c78bf5eff04ce4fbc92b826cf14d0a36b47 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Sun, 29 Nov 2015 22:24:16 +0100 Subject: [PATCH 10/40] Upgrade project settings for iOS9 --- PSCCoreDataStack.xcodeproj/project.pbxproj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index 02a1c85..a04a0c2 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -174,7 +174,7 @@ isa = PBXProject; attributes = { LastTestingUpgradeCheck = 0510; - LastUpgradeCheck = 0460; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = PocketScience; }; buildConfigurationList = 9B5FDB1116FC65AB002FA5A6 /* Build configuration list for PBXProject "PSCCoreDataStack" */; @@ -235,6 +235,7 @@ CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_OPTIMIZATION_LEVEL = 0; From 2282b041750571222ae1795aca393f81a60b633e Mon Sep 17 00:00:00 2001 From: Alexander Wolf Date: Mon, 4 Jan 2016 10:42:24 +0100 Subject: [PATCH 11/40] Added podscpecs --- PSCCoreDataStack.podspec | 23 +++++++++++++++++++ .../contents.xcworkspacedata | 7 ++++++ 2 files changed, 30 insertions(+) create mode 100644 PSCCoreDataStack.podspec create mode 100644 PSCCoreDataStack.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/PSCCoreDataStack.podspec b/PSCCoreDataStack.podspec new file mode 100644 index 0000000..9f19be2 --- /dev/null +++ b/PSCCoreDataStack.podspec @@ -0,0 +1,23 @@ +Pod::Spec.new do |s| + s.name = 'PSCCoreDataStack' + s.version = '0.0.9' + + s.summary = 'A persistence layer for CoreData' + s.description = <<-DESC + This library can be used for easier access to basic CoreData functionality + have fun. + DESC + + s.homepage = 'http://nousguide.com/' + s.documentation_url = 'http://nousguide.com/help/' + + s.license = { :type => 'MIT', :file => 'LICENCE.md' } + s.author = { 'Thomas Heingaertner' => 'mail@t.heingaertner@nousguide.com', 'Alexander Wold' => 'mail@a.wolf@nousguide.com' } + s.source = { :git => 'https://github.com/PocketScientists/PSCCoreDataStack.git', :tag => s.version.to_s } + + s.platform = :ios, '5.0' + s.source_files = 'PSCCoreDataStack/*.{h,m}' + s.requires_arc = true + + s.frameworks = 'CoreData' +end diff --git a/PSCCoreDataStack.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/PSCCoreDataStack.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/PSCCoreDataStack.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + From c24dc539e44ccdc2cc09b467cce29d66226bcdf3 Mon Sep 17 00:00:00 2001 From: Alexander Wolf Date: Mon, 4 Jan 2016 10:50:31 +0100 Subject: [PATCH 12/40] corrected reference to license file --- PSCCoreDataStack.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PSCCoreDataStack.podspec b/PSCCoreDataStack.podspec index 9f19be2..167cbf8 100644 --- a/PSCCoreDataStack.podspec +++ b/PSCCoreDataStack.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.homepage = 'http://nousguide.com/' s.documentation_url = 'http://nousguide.com/help/' - s.license = { :type => 'MIT', :file => 'LICENCE.md' } + s.license = { :file => 'LICENCE' } s.author = { 'Thomas Heingaertner' => 'mail@t.heingaertner@nousguide.com', 'Alexander Wold' => 'mail@a.wolf@nousguide.com' } s.source = { :git => 'https://github.com/PocketScientists/PSCCoreDataStack.git', :tag => s.version.to_s } From 2665bb188a1039b1bd80ead5d617dbee1f9c2b8b Mon Sep 17 00:00:00 2001 From: Alexander Wolf Date: Mon, 4 Jan 2016 10:52:35 +0100 Subject: [PATCH 13/40] correceted license filename --- PSCCoreDataStack.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PSCCoreDataStack.podspec b/PSCCoreDataStack.podspec index 167cbf8..bcd0bc1 100644 --- a/PSCCoreDataStack.podspec +++ b/PSCCoreDataStack.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.homepage = 'http://nousguide.com/' s.documentation_url = 'http://nousguide.com/help/' - s.license = { :file => 'LICENCE' } + s.license = { :file => 'LICENSE' } s.author = { 'Thomas Heingaertner' => 'mail@t.heingaertner@nousguide.com', 'Alexander Wold' => 'mail@a.wolf@nousguide.com' } s.source = { :git => 'https://github.com/PocketScientists/PSCCoreDataStack.git', :tag => s.version.to_s } From fd68f64763bc441c66d9ec9c9bd7c8e630369c8e Mon Sep 17 00:00:00 2001 From: Alexander Wolf Date: Mon, 4 Jan 2016 11:02:28 +0100 Subject: [PATCH 14/40] Added CoreData imports to header files --- PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h | 1 + PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h | 1 + PSCCoreDataStack/PSCContextWatcher.h | 1 + PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h | 2 ++ PSCCoreDataStack/PSCPersistenceOperation.h | 2 +- 5 files changed, 6 insertions(+), 1 deletion(-) diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h index a63857b..56fbbf3 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h @@ -6,6 +6,7 @@ // Copyright (c) 2013 Philip Messlehner. All rights reserved. // +#import @class PSCContextWatcher; diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h index 666081d..cde1fed 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h @@ -6,6 +6,7 @@ // Copyright (c) 2013 Philip Messlehner. All rights reserved. // +#import @interface NSManagedObjectContext (PSCCoreDataHelper) diff --git a/PSCCoreDataStack/PSCContextWatcher.h b/PSCCoreDataStack/PSCContextWatcher.h index 10f2df6..cc22960 100644 --- a/PSCCoreDataStack/PSCContextWatcher.h +++ b/PSCCoreDataStack/PSCContextWatcher.h @@ -28,6 +28,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. +#import @protocol PSCContextWatcherDelegate; diff --git a/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h b/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h index 4023d46..2c54ac7 100644 --- a/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h +++ b/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h @@ -38,6 +38,8 @@ */ +#import + extern NSString *const PSCFetchedResultsControllerUpdaterControllerDidChangeContentNotification; @interface PSCFetchedResultsControllerUpdater : NSObject diff --git a/PSCCoreDataStack/PSCPersistenceOperation.h b/PSCCoreDataStack/PSCPersistenceOperation.h index 8e9fdca..bc07084 100644 --- a/PSCCoreDataStack/PSCPersistenceOperation.h +++ b/PSCCoreDataStack/PSCPersistenceOperation.h @@ -7,7 +7,7 @@ // #import - +#import typedef BOOL(^psc_persistence_block)(NSManagedObjectContext *localContext); From c85b2631a4d7e78cbf015f4f2f044b5ac2c91a32 Mon Sep 17 00:00:00 2001 From: Juergen Date: Mon, 22 Feb 2016 10:25:25 +0100 Subject: [PATCH 15/40] added saveAndPropagateToParentContextBlockingDoNotSaveParentContext to fix grandParentIssue --- ...NSManagedObjectContext+PSCCoreDataHelper.h | 2 +- ...NSManagedObjectContext+PSCCoreDataHelper.m | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h index cde1fed..13393dc 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h @@ -14,8 +14,8 @@ - (BOOL)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContextBlocking:success:failure' instead"))); - (BOOL)saveAndPropagateToParentContext:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContexWithSuccess:failure' instead"))); - - (BOOL)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)())sucess failure:(void(^)(NSError *error))failure; +- (BOOL)saveAndPropagateToParentContextBlockingDoNotSaveParentContext:(BOOL)wait success:(void(^)())successBlock failure:(void(^)(NSError *error))failureBlock; //added by JGRU due to grandchild context issues - (BOOL)saveAndPropagateToParentContextWithSuccess:(void(^)())sucess failure:(void(^)(NSError *error))failure; @end diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m index 473546b..70aa16a 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m @@ -102,6 +102,35 @@ - (BOOL)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)())su return success; } +- (BOOL)saveAndPropagateToParentContextBlockingDoNotSaveParentContext:(BOOL)wait success:(void(^)())successBlock failure:(void(^)(NSError *error))failureBlock { + __block BOOL success = YES; + __block NSError *error = nil; + if (self.hasChanges) { + if (self.concurrencyType == NSConfinementConcurrencyType) { + success = [self save:&error]; + } else { + [self performBlockAndWait:^{ + success = [self save:&error]; + }]; + } + } + + if (!success) { + if (failureBlock) { + failureBlock(error); + } + return NO; + } + +if (success && successBlock) { + successBlock(); + } + + return success; +} + + + - (BOOL)saveAndPropagateToParentContextWithSuccess:(void(^)())successBlock failure:(void(^)(NSError *error))failureBlock { return [self saveAndPropagateToParentContextBlocking:NO success:successBlock failure:failureBlock]; } From 35f6039579ee7206a88d7b0454b6149a15a25f90 Mon Sep 17 00:00:00 2001 From: Juergen Date: Thu, 3 Mar 2016 14:58:59 +0100 Subject: [PATCH 16/40] check for error on initialization and return error block on setupWithModelURL --- PSCCoreDataStack/PSCCoreDataStack.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/PSCCoreDataStack/PSCCoreDataStack.m b/PSCCoreDataStack/PSCCoreDataStack.m index f27e4f1..841cc17 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.m +++ b/PSCCoreDataStack/PSCCoreDataStack.m @@ -60,6 +60,13 @@ + (void)setupWithModelURL:(NSURL *)modelURL URL:storeURL options:options error:&error]; + if(error != nil){ + if (errorBlock != nil) { + dispatch_async(dispatch_get_main_queue(), ^{ + errorBlock(error); + }); + } + } if (store == nil) { PSCCDLog(@"Error adding persistent store to coordinator %@\n%@", [error localizedDescription], [error userInfo]); From 4dd79a6d5b5c076633428efe60bdfbbd3f4e84e1 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Thu, 10 Mar 2016 21:24:54 +0100 Subject: [PATCH 17/40] Made all calls asynchronous --- PSCCoreDataStack.xcodeproj/project.pbxproj | 8 +- ...NSManagedObjectContext+PSCCoreDataHelper.h | 8 +- ...NSManagedObjectContext+PSCCoreDataHelper.m | 140 ++++++++++-------- 3 files changed, 83 insertions(+), 73 deletions(-) diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index a04a0c2..43a1d4b 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -226,8 +226,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -247,7 +245,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; @@ -257,8 +255,6 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -270,7 +266,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 7.0; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h index 666081d..0503355 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h @@ -11,10 +11,10 @@ - (NSManagedObjectContext *)newChildContextWithConcurrencyType:(NSUInteger)concurrencyType; -- (BOOL)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContextBlocking:success:failure' instead"))); -- (BOOL)saveAndPropagateToParentContext:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContexWithSuccess:failure' instead"))); +- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContextBlocking:success:failure' instead"))); +- (void)saveAndPropagateToParentContext:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContexWithSuccess:failure' instead"))); -- (BOOL)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)())sucess failure:(void(^)(NSError *error))failure; -- (BOOL)saveAndPropagateToParentContextWithSuccess:(void(^)())sucess failure:(void(^)(NSError *error))failure; +- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)())sucess failure:(void(^)(NSError *error))failure; +- (void)saveAndPropagateToParentContextWithSuccess:(void(^)())sucess failure:(void(^)(NSError *error))failure; @end diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m index 473546b..f3f7348 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m @@ -18,92 +18,106 @@ - (NSManagedObjectContext *)newChildContextWithConcurrencyType:(NSUInteger)concu return childContext; } -- (BOOL)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(__autoreleasing NSError **)error { - __block BOOL success = YES; +- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(__autoreleasing NSError **)error { + dispatch_block_t parentCheck = ^{ + if (self.parentContext.hasChanges) { + dispatch_block_t saveParent = ^{ + [self.parentContext save:error]; + }; + + if (self.parentContext.concurrencyType == NSConfinementConcurrencyType) { + saveParent(); + } else if (wait) { + [self.parentContext performBlockAndWait:saveParent]; + } else { + [self.parentContext performBlock:saveParent]; + } + } + }; if (self.hasChanges) { if (self.concurrencyType == NSConfinementConcurrencyType) { - success = [self save:error]; - } else { + if ([self save:error]) { + parentCheck(); + } + } else if (wait) { [self performBlockAndWait:^{ - success = [self save:error]; + if ([self save:error]) { + parentCheck(); + } }]; } - } - - if (!success) { - return NO; - } - - if (self.parentContext.hasChanges) { - dispatch_block_t saveParent = ^{ - success = [self.parentContext save:error]; - }; - - if (self.parentContext.concurrencyType == NSConfinementConcurrencyType) { - saveParent(); - } else if (wait) { - [self.parentContext performBlockAndWait:saveParent]; - } else { - [self.parentContext performBlock:saveParent]; + else { + [self performBlock:^{ + if ([self save:error]) { + parentCheck(); + } + }]; } } - - return success; + else { + parentCheck(); + } } -- (BOOL)saveAndPropagateToParentContext:(__autoreleasing NSError **)error { - return [self saveAndPropagateToParentContextBlocking:NO error:error]; +- (void)saveAndPropagateToParentContext:(__autoreleasing NSError **)error { + [self saveAndPropagateToParentContextBlocking:NO error:error]; } -- (BOOL)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)())successBlock failure:(void(^)(NSError *error))failureBlock { - __block BOOL success = YES; - __block NSError *error = nil; - if (self.hasChanges) { - if (self.concurrencyType == NSConfinementConcurrencyType) { - success = [self save:&error]; - } else { - [self performBlockAndWait:^{ - success = [self save:&error]; - }]; - } - } - - if (!success) { - if (failureBlock) { - failureBlock(error); +- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)())successBlock failure:(void(^)(NSError *error))failureBlock { + dispatch_block_t parentCheck = ^{ + if (self.parentContext.hasChanges) { + dispatch_block_t saveParent = ^{ + NSError *error = nil; + if ([self.parentContext save:&error]) { + if (successBlock) { + successBlock(); + } + } else if (failureBlock) { + failureBlock(error); + } + }; + + if (self.parentContext.concurrencyType == NSConfinementConcurrencyType) { + saveParent(); + } else if (wait) { + [self.parentContext performBlockAndWait:saveParent]; + } else { + [self.parentContext performBlock:saveParent]; + } + } else if (successBlock) { + successBlock(); } - return NO; - } + }; - if (self.parentContext.hasChanges) { - dispatch_block_t saveParent = ^{ - success = [self.parentContext save:&error]; - if (success) { - if (successBlock) { - successBlock(); + if (self.hasChanges) { + dispatch_block_t saveChild = ^{ + NSError *error = nil; + if ([self save:&error]) { + parentCheck(); + } + else { + if (failureBlock) { + failureBlock(error); } - } else if (failureBlock) { - failureBlock(error); } }; - - if (self.parentContext.concurrencyType == NSConfinementConcurrencyType) { - saveParent(); + + if (self.concurrencyType == NSConfinementConcurrencyType) { + saveChild(); } else if (wait) { - [self.parentContext performBlockAndWait:saveParent]; + [self performBlockAndWait:saveChild]; } else { - [self.parentContext performBlock:saveParent]; + [self performBlock:saveChild]; } - } else if (success && successBlock) { - successBlock(); } - - return success; + else { + parentCheck(); + } } -- (BOOL)saveAndPropagateToParentContextWithSuccess:(void(^)())successBlock failure:(void(^)(NSError *error))failureBlock { - return [self saveAndPropagateToParentContextBlocking:NO success:successBlock failure:failureBlock]; +- (void)saveAndPropagateToParentContextWithSuccess:(void(^)())successBlock failure:(void(^)(NSError *error))failureBlock { + [self saveAndPropagateToParentContextBlocking:NO success:successBlock failure:failureBlock]; } @end From e05ddd05e2c79d214678085c9f7fbe6d0db1b683 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Fri, 30 Sep 2016 11:12:16 +0200 Subject: [PATCH 18/40] Upgraded tests --- PSCCoreDataStackTests/PSCCoreDataStackTests.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PSCCoreDataStackTests/PSCCoreDataStackTests.h b/PSCCoreDataStackTests/PSCCoreDataStackTests.h index 3ad88c6..64870c7 100644 --- a/PSCCoreDataStackTests/PSCCoreDataStackTests.h +++ b/PSCCoreDataStackTests/PSCCoreDataStackTests.h @@ -6,8 +6,8 @@ // Copyright (c) 2013 PocketScience. All rights reserved. // -#import +#import -@interface PSCCoreDataStackTests : SenTestCase +@interface PSCCoreDataStackTests : XCTestCase @end From 14179a3d6c2a62b81738409e84bb4e3117e3a895 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Fri, 30 Sep 2016 11:12:24 +0200 Subject: [PATCH 19/40] Upgrade to Xcode 8 --- PSCCoreDataStack.xcodeproj/project.pbxproj | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index 43a1d4b..11e8265 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -174,7 +174,7 @@ isa = PBXProject; attributes = { LastTestingUpgradeCheck = 0510; - LastUpgradeCheck = 0710; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = PocketScience; }; buildConfigurationList = 9B5FDB1116FC65AB002FA5A6 /* Build configuration list for PBXProject "PSCCoreDataStack" */; @@ -227,25 +227,34 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; @@ -256,17 +265,26 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; + ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; From 33e564c299e5144ee068f34902b704bc162a218c Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Tue, 21 Nov 2017 23:31:02 +0100 Subject: [PATCH 20/40] Upgraded to iOS 11 and Xcode 9 --- PSCCoreDataStack.xcodeproj/project.pbxproj | 14 ++++++++- .../contents.xcworkspacedata | 7 +++++ .../PSCCoreDataStack.xcscmblueprint | 30 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 PSCCoreDataStack.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 PSCCoreDataStack.xcodeproj/project.xcworkspace/xcshareddata/PSCCoreDataStack.xcscmblueprint diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index 11e8265..cfeb82b 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -174,7 +174,7 @@ isa = PBXProject; attributes = { LastTestingUpgradeCheck = 0510; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = PocketScience; }; buildConfigurationList = 9B5FDB1116FC65AB002FA5A6 /* Build configuration list for PBXProject "PSCCoreDataStack" */; @@ -227,12 +227,18 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -265,12 +271,18 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; diff --git a/PSCCoreDataStack.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/PSCCoreDataStack.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/PSCCoreDataStack.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/PSCCoreDataStack.xcodeproj/project.xcworkspace/xcshareddata/PSCCoreDataStack.xcscmblueprint b/PSCCoreDataStack.xcodeproj/project.xcworkspace/xcshareddata/PSCCoreDataStack.xcscmblueprint new file mode 100644 index 0000000..baf20a5 --- /dev/null +++ b/PSCCoreDataStack.xcodeproj/project.xcworkspace/xcshareddata/PSCCoreDataStack.xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "D261E0A4710B0DA4CAA16F150E6AB7046AB2576A", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "D261E0A4710B0DA4CAA16F150E6AB7046AB2576A" : 9223372036854775807, + "5CAD9AD776377F08EC40032FFD796FFA54F88822" : 9223372036854775807 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "5385F887-07A2-4B63-A6A2-92D5CD1792C8", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "D261E0A4710B0DA4CAA16F150E6AB7046AB2576A" : "PSCCoreDataStack\/", + "5CAD9AD776377F08EC40032FFD796FFA54F88822" : "" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "PSCCoreDataStack", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "PSCCoreDataStack.xcodeproj", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/sources-headless.app.redbull.com\/scm\/fft\/bullchecker-client.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "5CAD9AD776377F08EC40032FFD796FFA54F88822" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/sources-headless.app.redbull.com\/scm\/fft\/psccoredatastack.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "D261E0A4710B0DA4CAA16F150E6AB7046AB2576A" + } + ] +} \ No newline at end of file From 2f6a32dd722b11697d1d0962c63756d0030c2e48 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Tue, 21 Nov 2017 23:31:19 +0100 Subject: [PATCH 21/40] Fixed prototype warnings --- .../NSManagedObjectContext+PSCCoreDataHelper.h | 4 ++-- .../NSManagedObjectContext+PSCCoreDataHelper.m | 4 ++-- PSCCoreDataStack/PSCCoreDataStack.h | 8 ++++---- PSCCoreDataStack/PSCCoreDataStack.m | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h index 0503355..8199431 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h @@ -14,7 +14,7 @@ - (void)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContextBlocking:success:failure' instead"))); - (void)saveAndPropagateToParentContext:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContexWithSuccess:failure' instead"))); -- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)())sucess failure:(void(^)(NSError *error))failure; -- (void)saveAndPropagateToParentContextWithSuccess:(void(^)())sucess failure:(void(^)(NSError *error))failure; +- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)(void))sucess failure:(void(^)(NSError *error))failure; +- (void)saveAndPropagateToParentContextWithSuccess:(void(^)(void))sucess failure:(void(^)(NSError *error))failure; @end diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m index f3f7348..96e9ee9 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m @@ -64,7 +64,7 @@ - (void)saveAndPropagateToParentContext:(__autoreleasing NSError **)error { [self saveAndPropagateToParentContextBlocking:NO error:error]; } -- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)())successBlock failure:(void(^)(NSError *error))failureBlock { +- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)(void))successBlock failure:(void(^)(NSError *error))failureBlock { dispatch_block_t parentCheck = ^{ if (self.parentContext.hasChanges) { dispatch_block_t saveParent = ^{ @@ -116,7 +116,7 @@ - (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)())su } } -- (void)saveAndPropagateToParentContextWithSuccess:(void(^)())successBlock failure:(void(^)(NSError *error))failureBlock { +- (void)saveAndPropagateToParentContextWithSuccess:(void(^)(void))successBlock failure:(void(^)(NSError *error))failureBlock { [self saveAndPropagateToParentContextBlocking:NO success:successBlock failure:failureBlock]; } diff --git a/PSCCoreDataStack/PSCCoreDataStack.h b/PSCCoreDataStack/PSCCoreDataStack.h index f6e1ac9..22bfc54 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.h +++ b/PSCCoreDataStack/PSCCoreDataStack.h @@ -23,18 +23,18 @@ storeURL:(NSURL *)storeURL configuration:(NSString *)configuration options:(NSDictionary *)options - success:(void(^)())successBlock + success:(void(^)(void))successBlock error:(void(^)(NSError *error))errorBlock; + (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName - success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock; + success:(void(^)(void))successBlock error:(void(^)(NSError *error))errorBlock; + (void)saveAndPersistContextBlocking:(BOOL)wait; + (void)saveAndPersistContext; -+ (void)saveAndPersistContextBlocking:(BOOL)wait success:(void(^)())sucessBlock error:(void(^)(NSError *error))errorBlock; -+ (void)saveAndPersistContextWithSuccess:(void(^)())sucessBlock error:(void(^)(NSError *error))errorBlock; ++ (void)saveAndPersistContextBlocking:(BOOL)wait success:(void(^)(void))sucessBlock error:(void(^)(NSError *error))errorBlock; ++ (void)saveAndPersistContextWithSuccess:(void(^)(void))sucessBlock error:(void(^)(NSError *error))errorBlock; + (NSManagedObjectContext *)mainContext; + (NSManagedObjectContext *)newChildContextWithPrivateQueue; diff --git a/PSCCoreDataStack/PSCCoreDataStack.m b/PSCCoreDataStack/PSCCoreDataStack.m index 6eb3161..9e15965 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.m +++ b/PSCCoreDataStack/PSCCoreDataStack.m @@ -26,7 +26,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL storeURL:(NSURL *)storeURL configuration:(NSString *)configuration options:(NSDictionary *)options - success:(void(^)())successBlock + success:(void(^)(void))successBlock error:(void(^)(NSError *error))errorBlock { NSParameterAssert(modelURL != nil); @@ -81,7 +81,7 @@ + (void)setupWithModelURL:(NSURL *)modelURL }); } -+ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName success:(void(^)())successBlock error:(void(^)(NSError *error))errorBlock { ++ (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName success:(void(^)(void))successBlock error:(void(^)(NSError *error))errorBlock { NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption: @(YES), NSInferMappingModelAutomaticallyOption: @(YES)}; [self setupWithModelURL:modelURL @@ -106,7 +106,7 @@ + (void)saveAndPersistContext { [self saveAndPersistContextBlocking:NO]; } -+ (void)saveAndPersistContextBlocking:(BOOL)wait success:(void(^)())sucessBlock error:(void(^)(NSError *error))errorBlock { ++ (void)saveAndPersistContextBlocking:(BOOL)wait success:(void(^)(void))sucessBlock error:(void(^)(NSError *error))errorBlock { [[self mainContext] saveAndPropagateToParentContextBlocking:wait success:sucessBlock failure:^(NSError *error) { PSCCDLog(@"%@ %@", [error localizedDescription], [error userInfo]); if (errorBlock) { @@ -115,7 +115,7 @@ + (void)saveAndPersistContextBlocking:(BOOL)wait success:(void(^)())sucessBlock }]; } -+ (void)saveAndPersistContextWithSuccess:(void(^)())sucessBlock error:(void(^)(NSError *error))errorBlock { ++ (void)saveAndPersistContextWithSuccess:(void(^)(void))sucessBlock error:(void(^)(NSError *error))errorBlock { [self saveAndPersistContextBlocking:NO success:sucessBlock error:errorBlock]; } From d5d6cfefa08a2a1ecba0789206293646641f37f4 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Mon, 25 Dec 2017 17:34:31 +0100 Subject: [PATCH 22/40] Converted to Framework --- PSCCoreData/Info.plist | 24 +++ PSCCoreData/PSCCoreData.h | 19 ++ PSCCoreDataStack.xcodeproj/project.pbxproj | 193 ++++++++++++++++++ .../xcschemes/PSCCoreData.xcscheme | 82 ++++++++ .../NSManagedObject+PSCCoreDataHelper.h | 2 +- ...NSManagedObjectContext+PSCCoreDataHelper.h | 1 + PSCCoreDataStack/PSCContextWatcher.h | 1 + .../PSCFetchedResultsControllerUpdater.h | 2 + .../PSCFetchedResultsControllerUpdater.m | 1 + PSCCoreDataStack/PSCPersistenceOperation.h | 1 + 10 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 PSCCoreData/Info.plist create mode 100644 PSCCoreData/PSCCoreData.h create mode 100644 PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme diff --git a/PSCCoreData/Info.plist b/PSCCoreData/Info.plist new file mode 100644 index 0000000..1007fd9 --- /dev/null +++ b/PSCCoreData/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/PSCCoreData/PSCCoreData.h b/PSCCoreData/PSCCoreData.h new file mode 100644 index 0000000..351a8ac --- /dev/null +++ b/PSCCoreData/PSCCoreData.h @@ -0,0 +1,19 @@ +// +// PSCCoreData.h +// PSCCoreData +// +// Created by Juergen Falb on 25.12.17. +// Copyright © 2017 PocketScience. All rights reserved. +// + +#import + +//! Project version number for PSCCoreData. +FOUNDATION_EXPORT double PSCCoreDataVersionNumber; + +//! Project version string for PSCCoreData. +FOUNDATION_EXPORT const unsigned char PSCCoreDataVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index cfeb82b..b405543 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -16,6 +16,22 @@ 9B5FDB4E16FC660C002FA5A6 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB4D16FC660C002FA5A6 /* CoreData.framework */; }; 9B5FDB5916FC7025002FA5A6 /* PSCFetchedResultsControllerUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB5816FC7025002FA5A6 /* PSCFetchedResultsControllerUpdater.m */; }; 9B5FDB5B16FC7387002FA5A6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB5A16FC7387002FA5A6 /* UIKit.framework */; }; + A9BD92891FF15E9900F4B027 /* PSCCoreData.h in Headers */ = {isa = PBXBuildFile; fileRef = A9BD92871FF15E9900F4B027 /* PSCCoreData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9BD928D1FF15EC300F4B027 /* NSManagedObject+PSCCoreDataHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB4216FC65DA002FA5A6 /* NSManagedObject+PSCCoreDataHelper.m */; }; + A9BD928E1FF15EC600F4B027 /* NSManagedObjectContext+PSCCoreDataHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB4416FC65DA002FA5A6 /* NSManagedObjectContext+PSCCoreDataHelper.m */; }; + A9BD928F1FF15EC900F4B027 /* PSCContextWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB4616FC65DA002FA5A6 /* PSCContextWatcher.m */; }; + A9BD92901FF15ED000F4B027 /* PSCCoreDataStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB4816FC65DA002FA5A6 /* PSCCoreDataStack.m */; }; + A9BD92911FF15ED500F4B027 /* PSCFetchedResultsControllerUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B5FDB5816FC7025002FA5A6 /* PSCFetchedResultsControllerUpdater.m */; }; + A9BD92921FF15ED900F4B027 /* PSCPersistenceOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B17A9F517025C8300DEF0B9 /* PSCPersistenceOperation.m */; }; + A9BD92931FF15F1100F4B027 /* NSManagedObject+PSCCoreDataHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5FDB4116FC65DA002FA5A6 /* NSManagedObject+PSCCoreDataHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9BD92941FF15F1400F4B027 /* NSManagedObjectContext+PSCCoreDataHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5FDB4316FC65DA002FA5A6 /* NSManagedObjectContext+PSCCoreDataHelper.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9BD92951FF15F1700F4B027 /* PSCContextWatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5FDB4516FC65DA002FA5A6 /* PSCContextWatcher.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9BD92961FF15F2100F4B027 /* PSCCoreDataStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5FDB4716FC65DA002FA5A6 /* PSCCoreDataStack.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9BD92971FF15F2500F4B027 /* PSCFetchedResultsControllerUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5FDB5716FC7025002FA5A6 /* PSCFetchedResultsControllerUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9BD92981FF15F3000F4B027 /* PSCPersistenceOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B17A9F417025C8300DEF0B9 /* PSCPersistenceOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9BD92991FF15F3300F4B027 /* PSCLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6B3C56170F5496004DFAD7 /* PSCLogging.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9BD929A1FF15F5100F4B027 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB4D16FC660C002FA5A6 /* CoreData.framework */; }; + A9BD929B1FF15FEE00F4B027 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB5A16FC7387002FA5A6 /* UIKit.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -54,6 +70,9 @@ 9B5FDB5816FC7025002FA5A6 /* PSCFetchedResultsControllerUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSCFetchedResultsControllerUpdater.m; sourceTree = ""; }; 9B5FDB5A16FC7387002FA5A6 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 9B6B3C56170F5496004DFAD7 /* PSCLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSCLogging.h; sourceTree = ""; }; + A9BD92851FF15E9900F4B027 /* PSCCoreData.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PSCCoreData.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A9BD92871FF15E9900F4B027 /* PSCCoreData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSCCoreData.h; sourceTree = ""; }; + A9BD92881FF15E9900F4B027 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -67,6 +86,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A9BD92811FF15E9900F4B027 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + A9BD929B1FF15FEE00F4B027 /* UIKit.framework in Frameworks */, + A9BD929A1FF15F5100F4B027 /* CoreData.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -74,6 +102,7 @@ isa = PBXGroup; children = ( 9B5FDB1B16FC65AB002FA5A6 /* PSCCoreDataStack */, + A9BD92861FF15E9900F4B027 /* PSCCoreData */, 9B5FDB1816FC65AB002FA5A6 /* Frameworks */, 9B5FDB3016FC65AC002FA5A6 /* PSCCoreDataStackTests */, 9B5FDB1716FC65AB002FA5A6 /* Products */, @@ -84,6 +113,7 @@ isa = PBXGroup; children = ( 9B5FDB1616FC65AB002FA5A6 /* libPSCCoreDataStack.a */, + A9BD92851FF15E9900F4B027 /* PSCCoreData.framework */, ); name = Products; sourceTree = ""; @@ -147,8 +177,35 @@ name = "Supporting Files"; sourceTree = ""; }; + A9BD92861FF15E9900F4B027 /* PSCCoreData */ = { + isa = PBXGroup; + children = ( + A9BD92871FF15E9900F4B027 /* PSCCoreData.h */, + A9BD92881FF15E9900F4B027 /* Info.plist */, + ); + path = PSCCoreData; + sourceTree = ""; + }; /* End PBXGroup section */ +/* Begin PBXHeadersBuildPhase section */ + A9BD92821FF15E9900F4B027 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + A9BD92891FF15E9900F4B027 /* PSCCoreData.h in Headers */, + A9BD92931FF15F1100F4B027 /* NSManagedObject+PSCCoreDataHelper.h in Headers */, + A9BD92941FF15F1400F4B027 /* NSManagedObjectContext+PSCCoreDataHelper.h in Headers */, + A9BD92951FF15F1700F4B027 /* PSCContextWatcher.h in Headers */, + A9BD92961FF15F2100F4B027 /* PSCCoreDataStack.h in Headers */, + A9BD92971FF15F2500F4B027 /* PSCFetchedResultsControllerUpdater.h in Headers */, + A9BD92981FF15F3000F4B027 /* PSCPersistenceOperation.h in Headers */, + A9BD92991FF15F3300F4B027 /* PSCLogging.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + /* Begin PBXNativeTarget section */ 9B5FDB1516FC65AB002FA5A6 /* PSCCoreDataStack */ = { isa = PBXNativeTarget; @@ -167,6 +224,24 @@ productReference = 9B5FDB1616FC65AB002FA5A6 /* libPSCCoreDataStack.a */; productType = "com.apple.product-type.library.static"; }; + A9BD92841FF15E9900F4B027 /* PSCCoreData */ = { + isa = PBXNativeTarget; + buildConfigurationList = A9BD928C1FF15E9900F4B027 /* Build configuration list for PBXNativeTarget "PSCCoreData" */; + buildPhases = ( + A9BD92801FF15E9900F4B027 /* Sources */, + A9BD92811FF15E9900F4B027 /* Frameworks */, + A9BD92821FF15E9900F4B027 /* Headers */, + A9BD92831FF15E9900F4B027 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = PSCCoreData; + productName = PSCCoreData; + productReference = A9BD92851FF15E9900F4B027 /* PSCCoreData.framework */; + productType = "com.apple.product-type.framework"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -176,6 +251,13 @@ LastTestingUpgradeCheck = 0510; LastUpgradeCheck = 0900; ORGANIZATIONNAME = PocketScience; + TargetAttributes = { + A9BD92841FF15E9900F4B027 = { + CreatedOnToolsVersion = 9.2; + DevelopmentTeam = Y6BEBK9HD8; + ProvisioningStyle = Automatic; + }; + }; }; buildConfigurationList = 9B5FDB1116FC65AB002FA5A6 /* Build configuration list for PBXProject "PSCCoreDataStack" */; compatibilityVersion = "Xcode 3.2"; @@ -190,10 +272,21 @@ projectRoot = ""; targets = ( 9B5FDB1516FC65AB002FA5A6 /* PSCCoreDataStack */, + A9BD92841FF15E9900F4B027 /* PSCCoreData */, ); }; /* End PBXProject section */ +/* Begin PBXResourcesBuildPhase section */ + A9BD92831FF15E9900F4B027 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 9B5FDB1216FC65AB002FA5A6 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -208,6 +301,19 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + A9BD92801FF15E9900F4B027 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A9BD92901FF15ED000F4B027 /* PSCCoreDataStack.m in Sources */, + A9BD928D1FF15EC300F4B027 /* NSManagedObject+PSCCoreDataHelper.m in Sources */, + A9BD928E1FF15EC600F4B027 /* NSManagedObjectContext+PSCCoreDataHelper.m in Sources */, + A9BD928F1FF15EC900F4B027 /* PSCContextWatcher.m in Sources */, + A9BD92921FF15ED900F4B027 /* PSCPersistenceOperation.m in Sources */, + A9BD92911FF15ED500F4B027 /* PSCFetchedResultsControllerUpdater.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ @@ -326,6 +432,84 @@ }; name = Release; }; + A9BD928A1FF15E9900F4B027 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = Y6BEBK9HD8; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = PSCCoreData/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.nousdigital.PSCCoreData; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + A9BD928B1FF15E9900F4B027 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = Y6BEBK9HD8; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_NS_ASSERTIONS = NO; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = PSCCoreData/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 11.2; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = com.nousdigital.PSCCoreData; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -347,6 +531,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + A9BD928C1FF15E9900F4B027 /* Build configuration list for PBXNativeTarget "PSCCoreData" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A9BD928A1FF15E9900F4B027 /* Debug */, + A9BD928B1FF15E9900F4B027 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 9B5FDB0E16FC65AB002FA5A6 /* Project object */; diff --git a/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme b/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme new file mode 100644 index 0000000..7b1ffd8 --- /dev/null +++ b/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h index a63857b..014ae35 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h @@ -5,7 +5,7 @@ // Created by Philip Messlehner on 28.02.13. // Copyright (c) 2013 Philip Messlehner. All rights reserved. // - +#import @class PSCContextWatcher; diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h index 8199431..49248f0 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h @@ -5,6 +5,7 @@ // Created by Philip Messlehner on 28.02.13. // Copyright (c) 2013 Philip Messlehner. All rights reserved. // +#import @interface NSManagedObjectContext (PSCCoreDataHelper) diff --git a/PSCCoreDataStack/PSCContextWatcher.h b/PSCCoreDataStack/PSCContextWatcher.h index 10f2df6..f9b87fe 100644 --- a/PSCCoreDataStack/PSCContextWatcher.h +++ b/PSCCoreDataStack/PSCContextWatcher.h @@ -27,6 +27,7 @@ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. +#import @protocol PSCContextWatcherDelegate; diff --git a/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h b/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h index 4023d46..08c7aee 100644 --- a/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h +++ b/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h @@ -7,6 +7,8 @@ // // Derived from MrRooni's Gist: https://gist.github.com/MrRooni/4988922 +#import + /** Controller that can be used to gather information about animated updates in a UITableView/UICollectionView. diff --git a/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.m b/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.m index b47449f..36e4303 100644 --- a/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.m +++ b/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.m @@ -7,6 +7,7 @@ // #import "PSCFetchedResultsControllerUpdater.h" +#import NSString *const PSCFetchedResultsControllerUpdaterControllerDidChangeContentNotification = @"PSCFetchedResultsControllerUpdaterControllerDidChangeContentNotification"; diff --git a/PSCCoreDataStack/PSCPersistenceOperation.h b/PSCCoreDataStack/PSCPersistenceOperation.h index 8e9fdca..24b4d88 100644 --- a/PSCCoreDataStack/PSCPersistenceOperation.h +++ b/PSCCoreDataStack/PSCPersistenceOperation.h @@ -7,6 +7,7 @@ // #import +#import typedef BOOL(^psc_persistence_block)(NSManagedObjectContext *localContext); From 4ce2738abfc5cc2211f8ca025f085362e9cddfb8 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Mon, 25 Dec 2017 17:42:38 +0100 Subject: [PATCH 23/40] Updated framework exports --- PSCCoreData/PSCCoreData.h | 8 ++++++-- PSCCoreDataStack.xcodeproj/project.pbxproj | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/PSCCoreData/PSCCoreData.h b/PSCCoreData/PSCCoreData.h index 351a8ac..51a764f 100644 --- a/PSCCoreData/PSCCoreData.h +++ b/PSCCoreData/PSCCoreData.h @@ -15,5 +15,9 @@ FOUNDATION_EXPORT double PSCCoreDataVersionNumber; FOUNDATION_EXPORT const unsigned char PSCCoreDataVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import - - +#import +#import +#import +#import +#import +#import diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index b405543..27b5994 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -29,7 +29,7 @@ A9BD92961FF15F2100F4B027 /* PSCCoreDataStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5FDB4716FC65DA002FA5A6 /* PSCCoreDataStack.h */; settings = {ATTRIBUTES = (Public, ); }; }; A9BD92971FF15F2500F4B027 /* PSCFetchedResultsControllerUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5FDB5716FC7025002FA5A6 /* PSCFetchedResultsControllerUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; }; A9BD92981FF15F3000F4B027 /* PSCPersistenceOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B17A9F417025C8300DEF0B9 /* PSCPersistenceOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - A9BD92991FF15F3300F4B027 /* PSCLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6B3C56170F5496004DFAD7 /* PSCLogging.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A9BD92991FF15F3300F4B027 /* PSCLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6B3C56170F5496004DFAD7 /* PSCLogging.h */; }; A9BD929A1FF15F5100F4B027 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB4D16FC660C002FA5A6 /* CoreData.framework */; }; A9BD929B1FF15FEE00F4B027 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9B5FDB5A16FC7387002FA5A6 /* UIKit.framework */; }; /* End PBXBuildFile section */ From 8e5a6d41e931d37619000cc10d5e168457c0c39a Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Tue, 2 Jan 2018 22:08:00 +0100 Subject: [PATCH 24/40] Fixed warning and changed target to 10.3 --- PSCCoreData/Info.plist | 2 +- PSCCoreDataStack.xcodeproj/project.pbxproj | 4 ++-- PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h | 2 +- .../NSManagedObjectContext+PSCCoreDataHelper.m | 8 ++------ 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/PSCCoreData/Info.plist b/PSCCoreData/Info.plist index 1007fd9..e234e4b 100644 --- a/PSCCoreData/Info.plist +++ b/PSCCoreData/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 1.0.3 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index 27b5994..8e8b743 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -458,7 +458,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = PSCCoreData/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; PRODUCT_BUNDLE_IDENTIFIER = com.nousdigital.PSCCoreData; @@ -498,7 +498,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; INFOPLIST_FILE = PSCCoreData/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 11.2; + IPHONEOS_DEPLOYMENT_TARGET = 10.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = com.nousdigital.PSCCoreData; diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h index 014ae35..fa29da9 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h @@ -57,7 +57,7 @@ typedef void(^psc_request_block)(NSFetchRequest *fetchRequest); deleteEntitiesNotInDictionary:(BOOL)deleteEntitiesNotInDictionary entityKeyInDictionary:(NSString *)dictionaryIDKeyPath entityKeyInDatabase:(NSString *)databaseIDKey - context:(NSManagedObjectContext *)contex + context:(NSManagedObjectContext *)context updateBlock:(void(^)(id managedObject, NSDictionary *data))updateBlock error:(NSError **)error; diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m index 96e9ee9..1e076a5 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m @@ -78,9 +78,7 @@ - (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)(void } }; - if (self.parentContext.concurrencyType == NSConfinementConcurrencyType) { - saveParent(); - } else if (wait) { + if (wait) { [self.parentContext performBlockAndWait:saveParent]; } else { [self.parentContext performBlock:saveParent]; @@ -103,9 +101,7 @@ - (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)(void } }; - if (self.concurrencyType == NSConfinementConcurrencyType) { - saveChild(); - } else if (wait) { + if (wait) { [self performBlockAndWait:saveChild]; } else { [self performBlock:saveChild]; From f121b272f10d616d53759df5b9be6811975861eb Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Fri, 30 Mar 2018 16:52:09 +0200 Subject: [PATCH 25/40] Upgraded to Xcode 9.3 and added nullability checks --- PSCCoreDataStack.xcodeproj/project.pbxproj | 8 ++++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++ .../xcschemes/PSCCoreData.xcscheme | 4 +-- .../NSManagedObject+PSCCoreDataHelper.h | 35 ++++++++++--------- ...NSManagedObjectContext+PSCCoreDataHelper.h | 11 +++--- PSCCoreDataStack/PSCContextWatcher.h | 11 +++--- PSCCoreDataStack/PSCCoreDataStack.h | 21 ++++++----- .../PSCFetchedResultsControllerUpdater.h | 12 ++++--- PSCCoreDataStack/PSCPersistenceOperation.h | 7 ++-- 9 files changed, 74 insertions(+), 43 deletions(-) create mode 100644 PSCCoreDataStack.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index 8e8b743..7012aeb 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -249,7 +249,7 @@ isa = PBXProject; attributes = { LastTestingUpgradeCheck = 0510; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = PocketScience; TargetAttributes = { A9BD92841FF15E9900F4B027 = { @@ -337,11 +337,13 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; @@ -381,11 +383,13 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; @@ -445,6 +449,7 @@ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = dwarf; @@ -483,6 +488,7 @@ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CODE_SIGN_STYLE = Automatic; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; diff --git a/PSCCoreDataStack.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/PSCCoreDataStack.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/PSCCoreDataStack.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme b/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme index 7b1ffd8..2ea9f5d 100644 --- a/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme +++ b/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme @@ -1,6 +1,6 @@ @@ -37,7 +36,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h index fa29da9..b63fb98 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h @@ -10,33 +10,34 @@ @class PSCContextWatcher; -typedef void(^psc_request_block)(NSFetchRequest *fetchRequest); +typedef void(^psc_request_block)(NSFetchRequest * _Nonnull fetchRequest); +NS_ASSUME_NONNULL_BEGIN @interface NSManagedObject (PSCCoreDataHelper) @property (nonatomic, readonly) NSManagedObjectID *permanentObjectID; + (instancetype)newObjectInContext:(NSManagedObjectContext *)context; -+ (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(id)value inContext:(NSManagedObjectContext *)context; ++ (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(nullable id)value inContext:(NSManagedObjectContext *)context; -+ (NSUInteger)deleteAllMatchingPredicate:(NSPredicate *)predicate - requestConfiguration:(psc_request_block)requestConfigurationBlock ++ (NSUInteger)deleteAllMatchingPredicate:(nullable NSPredicate *)predicate + requestConfiguration:(nullable psc_request_block)requestConfigurationBlock inContext:(NSManagedObjectContext *)context - error:(NSError **)error; -+ (NSUInteger)deleteAllMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError **)error; + error:(NSError * _Nullable * _Nullable)error; ++ (NSUInteger)deleteAllMatchingPredicate:(nullable NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; -+ (NSFetchRequest *)requestAllMatchingPredicate:(NSPredicate *)predicate error:(NSError **)error; -+ (NSFetchRequest *)requestFirstMatchingPredicate:(NSPredicate *)predicate error:(NSError **)error; ++ (NSFetchRequest *)requestAllMatchingPredicate:(NSPredicate *)predicate error:(NSError * _Nullable * _Nullable)error; ++ (NSFetchRequest *)requestFirstMatchingPredicate:(NSPredicate *)predicate error:(NSError * _Nullable * _Nullable)error; -+ (NSArray *)fetchAllMatchingPredicate:(NSPredicate *)predicate - requestConfiguration:(psc_request_block)requestConfigurationBlock - inContext:(NSManagedObjectContext *)context - error:(NSError **)error; -+ (NSArray *)fetchAllMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError **)error; -+ (instancetype)fetchFirstMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError **)error; ++ (nullable NSArray *)fetchAllMatchingPredicate:(NSPredicate *)predicate + requestConfiguration:(nullable psc_request_block)requestConfigurationBlock + inContext:(NSManagedObjectContext *)context + error:(NSError * _Nullable * _Nullable)error; ++ (nullable NSArray *)fetchAllMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; ++ (nullable instancetype)fetchFirstMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; -+ (NSUInteger)countOfObjectsMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError **)error; ++ (NSUInteger)countOfObjectsMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; /** High-level action to update the data in Core Data based on an array of dictionaries. @@ -59,7 +60,7 @@ typedef void(^psc_request_block)(NSFetchRequest *fetchRequest); entityKeyInDatabase:(NSString *)databaseIDKey context:(NSManagedObjectContext *)context updateBlock:(void(^)(id managedObject, NSDictionary *data))updateBlock - error:(NSError **)error; + error:(NSError * _Nullable * _Nullable)error; - (void)reset; - (void)deleteFromContext; @@ -67,3 +68,5 @@ typedef void(^psc_request_block)(NSFetchRequest *fetchRequest); - (id)userInfoValueForKey:(NSString *)key ofProperty:(NSString *)property; @end + +NS_ASSUME_NONNULL_END diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h index 49248f0..0ee1f9b 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h @@ -7,15 +7,18 @@ // #import +NS_ASSUME_NONNULL_BEGIN @interface NSManagedObjectContext (PSCCoreDataHelper) - (NSManagedObjectContext *)newChildContextWithConcurrencyType:(NSUInteger)concurrencyType; -- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContextBlocking:success:failure' instead"))); -- (void)saveAndPropagateToParentContext:(NSError **)error __attribute__((deprecated("use 'saveAndPropagateToParentContexWithSuccess:failure' instead"))); +- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(NSError * _Nullable * _Nullable)error __attribute__((deprecated("use 'saveAndPropagateToParentContextBlocking:success:failure' instead"))); +- (void)saveAndPropagateToParentContext:(NSError * _Nullable * _Nullable)error __attribute__((deprecated("use 'saveAndPropagateToParentContexWithSuccess:failure' instead"))); -- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)(void))sucess failure:(void(^)(NSError *error))failure; -- (void)saveAndPropagateToParentContextWithSuccess:(void(^)(void))sucess failure:(void(^)(NSError *error))failure; +- (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(nullable void(^)(void))sucess failure:(nullable void(^)(NSError *error))failure; +- (void)saveAndPropagateToParentContextWithSuccess:(nullable void(^)(void))sucess failure:(nullable void(^)(NSError *error))failure; @end + +NS_ASSUME_NONNULL_END diff --git a/PSCCoreDataStack/PSCContextWatcher.h b/PSCCoreDataStack/PSCContextWatcher.h index f9b87fe..d26e4b1 100644 --- a/PSCCoreDataStack/PSCContextWatcher.h +++ b/PSCCoreDataStack/PSCContextWatcher.h @@ -32,10 +32,11 @@ @protocol PSCContextWatcherDelegate; +NS_ASSUME_NONNULL_BEGIN @interface PSCContextWatcher : NSObject -@property (nonatomic, weak) id delegate; +@property (nullable, nonatomic, weak) id delegate; + (instancetype)watcherWithContext:(NSManagedObjectContext *)context; - (instancetype)initWithManagedObjectContext:(NSManagedObjectContext *)context; @@ -53,9 +54,11 @@ @protocol PSCContextWatcherDelegate - (void)contextWatcher:(PSCContextWatcher *)watcher - observedInsertions:(NSSet *)inserts - deletions:(NSSet *)deletions - updates:(NSSet *)updates + observedInsertions:(nullable NSSet *)inserts + deletions:(nullable NSSet *)deletions + updates:(nullable NSSet *)updates inContext:(NSManagedObjectContext *)context; @end + +NS_ASSUME_NONNULL_END diff --git a/PSCCoreDataStack/PSCCoreDataStack.h b/PSCCoreDataStack/PSCCoreDataStack.h index 22bfc54..007c833 100644 --- a/PSCCoreDataStack/PSCCoreDataStack.h +++ b/PSCCoreDataStack/PSCCoreDataStack.h @@ -14,27 +14,28 @@ #import "PSCFetchedResultsControllerUpdater.h" #import "PSCPersistenceOperation.h" +NS_ASSUME_NONNULL_BEGIN @interface PSCCoreDataStack : NSObject + (void)setupWithModelURL:(NSURL *)modelURL - storeFileName:(NSString *)storeFileName + storeFileName:(nullable NSString *)storeFileName type:(NSString *)storeType - storeURL:(NSURL *)storeURL - configuration:(NSString *)configuration - options:(NSDictionary *)options - success:(void(^)(void))successBlock - error:(void(^)(NSError *error))errorBlock; + storeURL:(nullable NSURL *)storeURL + configuration:(nullable NSString *)configuration + options:(nullable NSDictionary *)options + success:(nullable void(^)(void))successBlock + error:(nullable void(^)(NSError *error))errorBlock; + (void)setupWithModelURL:(NSURL *)modelURL autoMigratedSQLiteStoreFileName:(NSString *)storeFileName - success:(void(^)(void))successBlock error:(void(^)(NSError *error))errorBlock; + success:(nullable void(^)(void))successBlock error:(nullable void(^)(NSError *error))errorBlock; + (void)saveAndPersistContextBlocking:(BOOL)wait; + (void)saveAndPersistContext; -+ (void)saveAndPersistContextBlocking:(BOOL)wait success:(void(^)(void))sucessBlock error:(void(^)(NSError *error))errorBlock; -+ (void)saveAndPersistContextWithSuccess:(void(^)(void))sucessBlock error:(void(^)(NSError *error))errorBlock; ++ (void)saveAndPersistContextBlocking:(BOOL)wait success:(nullable void(^)(void))sucessBlock error:(nullable void(^)(NSError *error))errorBlock; ++ (void)saveAndPersistContextWithSuccess:(nullable void(^)(void))sucessBlock error:(nullable void(^)(NSError *error))errorBlock; + (NSManagedObjectContext *)mainContext; + (NSManagedObjectContext *)newChildContextWithPrivateQueue; @@ -42,3 +43,5 @@ autoMigratedSQLiteStoreFileName:(NSString *)storeFileName + (void)migratePersistentStoreToURL:(NSURL *)storeURL; @end + +NS_ASSUME_NONNULL_END diff --git a/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h b/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h index 08c7aee..089fd97 100644 --- a/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h +++ b/PSCCoreDataStack/PSCFetchedResultsControllerUpdater.h @@ -40,6 +40,8 @@ */ +NS_ASSUME_NONNULL_BEGIN + extern NSString *const PSCFetchedResultsControllerUpdaterControllerDidChangeContentNotification; @interface PSCFetchedResultsControllerUpdater : NSObject @@ -52,10 +54,10 @@ extern NSString *const PSCFetchedResultsControllerUpdaterControllerDidChangeCont @property (nonatomic, readonly) NSIndexSet *deletedSectionIndexes; @property (nonatomic, readonly) NSIndexSet *insertedSectionIndexes; -@property (nonatomic, readonly) NSArray *deletedObjectIndexPaths; -@property (nonatomic, readonly) NSArray *insertedObjectIndexPaths; -@property (nonatomic, readonly) NSArray *updatedObjectIndexPaths; -@property (nonatomic, readonly) NSArray *movedObjectIndexPaths; // only set if reportMovesAsInsertionsAndDeletions is NO +@property (nonatomic, readonly) NSArray *deletedObjectIndexPaths; +@property (nonatomic, readonly) NSArray *insertedObjectIndexPaths; +@property (nonatomic, readonly) NSArray *updatedObjectIndexPaths; +@property (nonatomic, readonly) NSArray *movedObjectIndexPaths; // only set if reportMovesAsInsertionsAndDeletions is NO - (void)reset; - (void)resetSectionChanges; @@ -70,3 +72,5 @@ extern NSString *const PSCFetchedResultsControllerUpdaterControllerDidChangeCont @property (nonatomic, strong) NSIndexPath *toIndexPath; @end + +NS_ASSUME_NONNULL_END diff --git a/PSCCoreDataStack/PSCPersistenceOperation.h b/PSCCoreDataStack/PSCPersistenceOperation.h index 24b4d88..02a099f 100644 --- a/PSCCoreDataStack/PSCPersistenceOperation.h +++ b/PSCCoreDataStack/PSCPersistenceOperation.h @@ -15,6 +15,7 @@ typedef BOOL(^psc_persistence_block)(NSManagedObjectContext *localContext); // the queue used in persistDataInBackgroundWithParentContext:block:completion: dispatch_queue_t psc_persistence_queue(void); +NS_ASSUME_NONNULL_BEGIN @interface PSCPersistenceOperation : NSOperation @@ -24,14 +25,14 @@ dispatch_queue_t psc_persistence_queue(void); */ + (void)persistDataInBackgroundWithParentContext:(NSManagedObjectContext *)parentContext block:(psc_persistence_block)block - completion:(dispatch_block_t)completion; + completion:(nullable dispatch_block_t)completion; /** Creates an NSOperation subclass that can be used to persist data to a local context */ + (instancetype)operationWithParentContext:(NSManagedObjectContext *)parentContext block:(psc_persistence_block)block - completion:(dispatch_block_t)completion; + completion:(nullable dispatch_block_t)completion; /** Subclasses can override to perform a persistence action */ - (BOOL)persistWithContext:(NSManagedObjectContext *)localContext; @@ -41,3 +42,5 @@ dispatch_queue_t psc_persistence_queue(void); - (void)didNotSaveContext:(NSManagedObjectContext *)localContext; @end + +NS_ASSUME_NONNULL_END From fa06c0fc3b255f5c75566622932fffa84eabed53 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Fri, 30 Mar 2018 17:31:13 +0200 Subject: [PATCH 26/40] Fixed nullability for fetching --- PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h index b63fb98..c39a8f9 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h @@ -27,17 +27,17 @@ NS_ASSUME_NONNULL_BEGIN error:(NSError * _Nullable * _Nullable)error; + (NSUInteger)deleteAllMatchingPredicate:(nullable NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; -+ (NSFetchRequest *)requestAllMatchingPredicate:(NSPredicate *)predicate error:(NSError * _Nullable * _Nullable)error; -+ (NSFetchRequest *)requestFirstMatchingPredicate:(NSPredicate *)predicate error:(NSError * _Nullable * _Nullable)error; ++ (NSFetchRequest *)requestAllMatchingPredicate:(nullable NSPredicate *)predicate error:(NSError * _Nullable * _Nullable)error; ++ (NSFetchRequest *)requestFirstMatchingPredicate:(nullable NSPredicate *)predicate error:(NSError * _Nullable * _Nullable)error; -+ (nullable NSArray *)fetchAllMatchingPredicate:(NSPredicate *)predicate ++ (nullable NSArray *)fetchAllMatchingPredicate:(nullable NSPredicate *)predicate requestConfiguration:(nullable psc_request_block)requestConfigurationBlock inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; -+ (nullable NSArray *)fetchAllMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; -+ (nullable instancetype)fetchFirstMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; ++ (nullable NSArray *)fetchAllMatchingPredicate:(nullable NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; ++ (nullable instancetype)fetchFirstMatchingPredicate:(nullable NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; -+ (NSUInteger)countOfObjectsMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; ++ (NSUInteger)countOfObjectsMatchingPredicate:(nullable NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError * _Nullable * _Nullable)error; /** High-level action to update the data in Core Data based on an array of dictionaries. From f687f96dd5fc4cadb0eb5fe91073fe4643286bcc Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Wed, 11 Apr 2018 17:27:46 +0200 Subject: [PATCH 27/40] Fixed type info --- PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h | 2 +- PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h index 0ee1f9b..cab50e8 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.h @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN @interface NSManagedObjectContext (PSCCoreDataHelper) -- (NSManagedObjectContext *)newChildContextWithConcurrencyType:(NSUInteger)concurrencyType; +- (NSManagedObjectContext *)newChildContextWithConcurrencyType:(NSManagedObjectContextConcurrencyType)concurrencyType; - (void)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(NSError * _Nullable * _Nullable)error __attribute__((deprecated("use 'saveAndPropagateToParentContextBlocking:success:failure' instead"))); - (void)saveAndPropagateToParentContext:(NSError * _Nullable * _Nullable)error __attribute__((deprecated("use 'saveAndPropagateToParentContexWithSuccess:failure' instead"))); diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m index 1e076a5..d518669 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m @@ -11,7 +11,7 @@ @implementation NSManagedObjectContext (PSCCoreDataHelper) -- (NSManagedObjectContext *)newChildContextWithConcurrencyType:(NSUInteger)concurrencyType { +- (NSManagedObjectContext *)newChildContextWithConcurrencyType:(NSManagedObjectContextConcurrencyType)concurrencyType { NSManagedObjectContext *childContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:concurrencyType]; childContext.parentContext = self; From a8d971081272abefe8d07ea3c85476f718a93c9c Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Thu, 9 Aug 2018 19:24:14 +0200 Subject: [PATCH 28/40] Added explicit nonnull --- PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h | 4 ++-- PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h index c39a8f9..1a35382 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h @@ -18,8 +18,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSManagedObjectID *permanentObjectID; -+ (instancetype)newObjectInContext:(NSManagedObjectContext *)context; -+ (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(nullable id)value inContext:(NSManagedObjectContext *)context; ++ (instancetype _Nonnull)newObjectInContext:(NSManagedObjectContext *)context; ++ (instancetype _Nonnull)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(nullable id)value inContext:(NSManagedObjectContext *)context; + (NSUInteger)deleteAllMatchingPredicate:(nullable NSPredicate *)predicate requestConfiguration:(nullable psc_request_block)requestConfigurationBlock diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m index 65e03e4..f1ee1c9 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m @@ -17,13 +17,13 @@ @implementation NSManagedObject (PSCCoreDataHelper) #pragma mark - Class Methods //////////////////////////////////////////////////////////////////////// -+ (instancetype)newObjectInContext:(NSManagedObjectContext *)context { ++ (instancetype _Nonnull)newObjectInContext:(NSManagedObjectContext *)context { NSParameterAssert(context != nil); return [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([self class]) inManagedObjectContext:context]; } -+ (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(id)value inContext:(NSManagedObjectContext *)context { ++ (instancetype _Nonnull)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(id)value inContext:(NSManagedObjectContext *)context { NSParameterAssert(attribute != nil); NSParameterAssert(context != nil); @@ -46,7 +46,7 @@ + (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingV [object setValue:value forKey:attribute]; } - return object; + return (id _Nonnull)object; } + (NSUInteger)deleteAllMatchingPredicate:(NSPredicate *)predicate requestConfiguration:(psc_request_block)requestConfigurationBlock inContext:(NSManagedObjectContext *)context error:(__autoreleasing NSError **)error { From 2510fa493998f1b03e45f7761a1725d0553b5801 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Thu, 9 Aug 2018 19:24:14 +0200 Subject: [PATCH 29/40] check for error on initialization and return error block on setupWithModelURL (+7 squashed commits) Squashed commits: [c85b263] added saveAndPropagateToParentContextBlockingDoNotSaveParentContext to fix grandParentIssue [fd68f64] Added CoreData imports to header files [2665bb1] correceted license filename [c24dc53] corrected reference to license file [2282b04] Added podscpecs [e51a757] Added method to truncate/clear SQLite DB [c5af683] build for all archs --- PSCCoreDataStack.podspec | 23 +++++++++++++++++++ .../NSManagedObject+PSCCoreDataHelper.h | 4 ++-- .../NSManagedObject+PSCCoreDataHelper.m | 6 ++--- 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 PSCCoreDataStack.podspec diff --git a/PSCCoreDataStack.podspec b/PSCCoreDataStack.podspec new file mode 100644 index 0000000..bcd0bc1 --- /dev/null +++ b/PSCCoreDataStack.podspec @@ -0,0 +1,23 @@ +Pod::Spec.new do |s| + s.name = 'PSCCoreDataStack' + s.version = '0.0.9' + + s.summary = 'A persistence layer for CoreData' + s.description = <<-DESC + This library can be used for easier access to basic CoreData functionality + have fun. + DESC + + s.homepage = 'http://nousguide.com/' + s.documentation_url = 'http://nousguide.com/help/' + + s.license = { :file => 'LICENSE' } + s.author = { 'Thomas Heingaertner' => 'mail@t.heingaertner@nousguide.com', 'Alexander Wold' => 'mail@a.wolf@nousguide.com' } + s.source = { :git => 'https://github.com/PocketScientists/PSCCoreDataStack.git', :tag => s.version.to_s } + + s.platform = :ios, '5.0' + s.source_files = 'PSCCoreDataStack/*.{h,m}' + s.requires_arc = true + + s.frameworks = 'CoreData' +end diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h index c39a8f9..1a35382 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h @@ -18,8 +18,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSManagedObjectID *permanentObjectID; -+ (instancetype)newObjectInContext:(NSManagedObjectContext *)context; -+ (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(nullable id)value inContext:(NSManagedObjectContext *)context; ++ (instancetype _Nonnull)newObjectInContext:(NSManagedObjectContext *)context; ++ (instancetype _Nonnull)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(nullable id)value inContext:(NSManagedObjectContext *)context; + (NSUInteger)deleteAllMatchingPredicate:(nullable NSPredicate *)predicate requestConfiguration:(nullable psc_request_block)requestConfigurationBlock diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m index 65e03e4..f1ee1c9 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m @@ -17,13 +17,13 @@ @implementation NSManagedObject (PSCCoreDataHelper) #pragma mark - Class Methods //////////////////////////////////////////////////////////////////////// -+ (instancetype)newObjectInContext:(NSManagedObjectContext *)context { ++ (instancetype _Nonnull)newObjectInContext:(NSManagedObjectContext *)context { NSParameterAssert(context != nil); return [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([self class]) inManagedObjectContext:context]; } -+ (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(id)value inContext:(NSManagedObjectContext *)context { ++ (instancetype _Nonnull)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(id)value inContext:(NSManagedObjectContext *)context { NSParameterAssert(attribute != nil); NSParameterAssert(context != nil); @@ -46,7 +46,7 @@ + (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingV [object setValue:value forKey:attribute]; } - return object; + return (id _Nonnull)object; } + (NSUInteger)deleteAllMatchingPredicate:(NSPredicate *)predicate requestConfiguration:(psc_request_block)requestConfigurationBlock inContext:(NSManagedObjectContext *)context error:(__autoreleasing NSError **)error { From afc79697bf82dec5833fd37450fd0e0ec991632b Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Thu, 28 Feb 2019 19:01:28 +0100 Subject: [PATCH 30/40] Revert "check for error on initialization and return error block on setupWithModelURL (+7 squashed commits)" This reverts commit 2510fa493998f1b03e45f7761a1725d0553b5801. --- PSCCoreDataStack.podspec | 23 ------------------- .../NSManagedObject+PSCCoreDataHelper.h | 4 ++-- .../NSManagedObject+PSCCoreDataHelper.m | 6 ++--- 3 files changed, 5 insertions(+), 28 deletions(-) delete mode 100644 PSCCoreDataStack.podspec diff --git a/PSCCoreDataStack.podspec b/PSCCoreDataStack.podspec deleted file mode 100644 index bcd0bc1..0000000 --- a/PSCCoreDataStack.podspec +++ /dev/null @@ -1,23 +0,0 @@ -Pod::Spec.new do |s| - s.name = 'PSCCoreDataStack' - s.version = '0.0.9' - - s.summary = 'A persistence layer for CoreData' - s.description = <<-DESC - This library can be used for easier access to basic CoreData functionality - have fun. - DESC - - s.homepage = 'http://nousguide.com/' - s.documentation_url = 'http://nousguide.com/help/' - - s.license = { :file => 'LICENSE' } - s.author = { 'Thomas Heingaertner' => 'mail@t.heingaertner@nousguide.com', 'Alexander Wold' => 'mail@a.wolf@nousguide.com' } - s.source = { :git => 'https://github.com/PocketScientists/PSCCoreDataStack.git', :tag => s.version.to_s } - - s.platform = :ios, '5.0' - s.source_files = 'PSCCoreDataStack/*.{h,m}' - s.requires_arc = true - - s.frameworks = 'CoreData' -end diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h index 1a35382..c39a8f9 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h @@ -18,8 +18,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSManagedObjectID *permanentObjectID; -+ (instancetype _Nonnull)newObjectInContext:(NSManagedObjectContext *)context; -+ (instancetype _Nonnull)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(nullable id)value inContext:(NSManagedObjectContext *)context; ++ (instancetype)newObjectInContext:(NSManagedObjectContext *)context; ++ (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(nullable id)value inContext:(NSManagedObjectContext *)context; + (NSUInteger)deleteAllMatchingPredicate:(nullable NSPredicate *)predicate requestConfiguration:(nullable psc_request_block)requestConfigurationBlock diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m index f1ee1c9..65e03e4 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m @@ -17,13 +17,13 @@ @implementation NSManagedObject (PSCCoreDataHelper) #pragma mark - Class Methods //////////////////////////////////////////////////////////////////////// -+ (instancetype _Nonnull)newObjectInContext:(NSManagedObjectContext *)context { ++ (instancetype)newObjectInContext:(NSManagedObjectContext *)context { NSParameterAssert(context != nil); return [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass([self class]) inManagedObjectContext:context]; } -+ (instancetype _Nonnull)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(id)value inContext:(NSManagedObjectContext *)context { ++ (instancetype)existingOrNewObjectWithAttribute:(NSString *)attribute matchingValue:(id)value inContext:(NSManagedObjectContext *)context { NSParameterAssert(attribute != nil); NSParameterAssert(context != nil); @@ -46,7 +46,7 @@ + (instancetype _Nonnull)existingOrNewObjectWithAttribute:(NSString *)attribute [object setValue:value forKey:attribute]; } - return (id _Nonnull)object; + return object; } + (NSUInteger)deleteAllMatchingPredicate:(NSPredicate *)predicate requestConfiguration:(psc_request_block)requestConfigurationBlock inContext:(NSManagedObjectContext *)context error:(__autoreleasing NSError **)error { From aa228bebf1aaffbb2fce46188972a45cdee5eebb Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Fri, 29 Mar 2019 17:58:06 +0100 Subject: [PATCH 31/40] Encapsulated hasChanges check --- PSCCoreDataStack.xcodeproj/project.pbxproj | 7 ++- .../xcschemes/PSCCoreData.xcscheme | 2 +- ...NSManagedObjectContext+PSCCoreDataHelper.m | 44 +++++++++---------- PSCCoreDataStack/PSCPersistenceOperation.h | 5 +-- PSCCoreDataStack/PSCPersistenceOperation.m | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index 7012aeb..0ab7ede 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -249,7 +249,7 @@ isa = PBXProject; attributes = { LastTestingUpgradeCheck = 0510; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = PocketScience; TargetAttributes = { A9BD92841FF15E9900F4B027 = { @@ -261,10 +261,11 @@ }; buildConfigurationList = 9B5FDB1116FC65AB002FA5A6 /* Build configuration list for PBXProject "PSCCoreDataStack" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 9B5FDB0D16FC65AB002FA5A6; productRefGroup = 9B5FDB1716FC65AB002FA5A6 /* Products */; @@ -332,6 +333,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; @@ -378,6 +380,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_ENABLE_OBJC_ARC = YES; CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; diff --git a/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme b/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme index 2ea9f5d..1bb0a44 100644 --- a/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme +++ b/PSCCoreDataStack.xcodeproj/xcshareddata/xcschemes/PSCCoreData.xcscheme @@ -1,6 +1,6 @@ #import +NS_ASSUME_NONNULL_BEGIN typedef BOOL(^psc_persistence_block)(NSManagedObjectContext *localContext); -// the queue used in persistDataInBackgroundWithParentContext:block:completion: -dispatch_queue_t psc_persistence_queue(void); - -NS_ASSUME_NONNULL_BEGIN @interface PSCPersistenceOperation : NSOperation diff --git a/PSCCoreDataStack/PSCPersistenceOperation.m b/PSCCoreDataStack/PSCPersistenceOperation.m index 43fe996..1d1c096 100644 --- a/PSCCoreDataStack/PSCPersistenceOperation.m +++ b/PSCCoreDataStack/PSCPersistenceOperation.m @@ -3,7 +3,7 @@ #import "NSManagedObjectContext+PSCCoreDataHelper.h" #import "PSCLogging.h" - +// the queue used in persistDataInBackgroundWithParentContext:block:completion: static dispatch_queue_t _psc_persistence_queue = NULL; From f80ebc9deebcd5a10c16eac3b56520aaec51d019 Mon Sep 17 00:00:00 2001 From: Michael Freimueller Date: Wed, 24 Jul 2019 09:05:23 +0200 Subject: [PATCH 32/40] implement new batch fetch functions --- .../NSManagedObject+PSCCoreDataHelper.h | 2 ++ .../NSManagedObject+PSCCoreDataHelper.m | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h index a63857b..20ca3cb 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.h @@ -27,6 +27,7 @@ typedef void(^psc_request_block)(NSFetchRequest *fetchRequest); + (NSUInteger)deleteAllMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError **)error; + (NSFetchRequest *)requestAllMatchingPredicate:(NSPredicate *)predicate error:(NSError **)error; ++ (NSFetchRequest *)requestBatchOfSize:(NSUInteger)batchSize atOffset:(NSUInteger)offset withMatchingPredicate:(NSPredicate *)predicate error:(__autoreleasing NSError **)error; + (NSFetchRequest *)requestFirstMatchingPredicate:(NSPredicate *)predicate error:(NSError **)error; + (NSArray *)fetchAllMatchingPredicate:(NSPredicate *)predicate @@ -35,6 +36,7 @@ typedef void(^psc_request_block)(NSFetchRequest *fetchRequest); error:(NSError **)error; + (NSArray *)fetchAllMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError **)error; + (instancetype)fetchFirstMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError **)error; ++ (NSArray *)fetchBatchOfSize:(NSUInteger)batchSize atOffset:(NSUInteger)offset withMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(__autoreleasing NSError **)error; + (NSUInteger)countOfObjectsMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError **)error; diff --git a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m index 65e03e4..6377823 100644 --- a/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObject+PSCCoreDataHelper.m @@ -86,6 +86,16 @@ + (NSFetchRequest *)requestAllMatchingPredicate:(NSPredicate *)predicate error:( return request; } ++ (NSFetchRequest *)requestBatchOfSize:(NSUInteger)batchSize atOffset:(NSUInteger)offset withMatchingPredicate:(NSPredicate *)predicate error:(__autoreleasing NSError **)error { + NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([self class])]; + + request.fetchLimit = batchSize; + request.fetchOffset = offset; + request.predicate = predicate; + + return request; +} + + (NSFetchRequest *)requestFirstMatchingPredicate:(NSPredicate *)predicate error:(NSError **)error { NSFetchRequest *request = [self requestAllMatchingPredicate:predicate error:error]; @@ -109,6 +119,13 @@ + (NSArray *)fetchAllMatchingPredicate:(NSPredicate *)predicate inContext:(NSMan return [self fetchAllMatchingPredicate:predicate requestConfiguration:nil inContext:context error:error]; } ++ (NSArray *)fetchBatchOfSize:(NSUInteger)batchSize atOffset:(NSUInteger)offset withMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(__autoreleasing NSError **)error { + NSFetchRequest *request = [self requestBatchOfSize:batchSize atOffset:offset withMatchingPredicate:predicate error:error]; + + NSArray *objects = [context executeFetchRequest:request error:error]; + return objects; +} + + (instancetype)fetchFirstMatchingPredicate:(NSPredicate *)predicate inContext:(NSManagedObjectContext *)context error:(NSError **)error { NSFetchRequest *fetchRequest = [self requestFirstMatchingPredicate:predicate error:error]; From 868962a112d2bd261617bce8c644aa3e5a9ef34f Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Sun, 24 Nov 2019 02:05:26 +0100 Subject: [PATCH 33/40] Added batch methods and podspec --- PSCCoreData.podspec | 23 ++++++++++++++++++++++ PSCCoreDataStack.xcodeproj/project.pbxproj | 2 ++ 2 files changed, 25 insertions(+) create mode 100644 PSCCoreData.podspec diff --git a/PSCCoreData.podspec b/PSCCoreData.podspec new file mode 100644 index 0000000..5ade889 --- /dev/null +++ b/PSCCoreData.podspec @@ -0,0 +1,23 @@ +Pod::Spec.new do |s| + s.platform = :ios, '11.0' + s.ios.deployment_target = '11.0' + s.name = "PSCCoreData" + s.version = "1.0.9" + s.license = 'MIT' + s.summary = "Helper for managing the CoreData Stack." + s.homepage = "https://github.com/PocketScientists/PSCCoreDataStack.git" + s.description = + 'Helper for managing the CoreData Stack. Contains extensions for NSManagedObject and NSManagedObjectContext' + s.authors = { + 'Jürgen Falb' => 'j.falb@nousdigital.net', + 'Philip Messlehner' => 'p.messlehner@pocketscience.com' + } + s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.9' } + s.source_files = 'PSCCoreDataStack/*.{h,m}', 'PSCCoreData/PSCCoreData.h' + + s.public_header_files = 'PSCCoreDataStack/*.{h}', 'PSCCoreData/PSCCoreData.h' + + s.frameworks = 'CoreData', 'Foundation', 'UIKit' + + s.requires_arc = true +end diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index 0ab7ede..192e1a3 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -70,6 +70,7 @@ 9B5FDB5816FC7025002FA5A6 /* PSCFetchedResultsControllerUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSCFetchedResultsControllerUpdater.m; sourceTree = ""; }; 9B5FDB5A16FC7387002FA5A6 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 9B6B3C56170F5496004DFAD7 /* PSCLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSCLogging.h; sourceTree = ""; }; + A96C0B40238A0B8300BF7682 /* PSCCoreData.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = PSCCoreData.podspec; sourceTree = ""; }; A9BD92851FF15E9900F4B027 /* PSCCoreData.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PSCCoreData.framework; sourceTree = BUILT_PRODUCTS_DIR; }; A9BD92871FF15E9900F4B027 /* PSCCoreData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSCCoreData.h; sourceTree = ""; }; A9BD92881FF15E9900F4B027 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -101,6 +102,7 @@ 9B5FDB0D16FC65AB002FA5A6 = { isa = PBXGroup; children = ( + A96C0B40238A0B8300BF7682 /* PSCCoreData.podspec */, 9B5FDB1B16FC65AB002FA5A6 /* PSCCoreDataStack */, A9BD92861FF15E9900F4B027 /* PSCCoreData */, 9B5FDB1816FC65AB002FA5A6 /* Frameworks */, From 812c97dbd17eaaeaf83725d532feadb1e0992951 Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Tue, 17 Nov 2020 17:34:51 +0100 Subject: [PATCH 34/40] Fixed carthage support --- PSCCoreDataStack.xcodeproj/project.pbxproj | 8 ++++++-- tmp.xcconfig | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tmp.xcconfig diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index 192e1a3..aa7d88f 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -70,6 +70,7 @@ 9B5FDB5816FC7025002FA5A6 /* PSCFetchedResultsControllerUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSCFetchedResultsControllerUpdater.m; sourceTree = ""; }; 9B5FDB5A16FC7387002FA5A6 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 9B6B3C56170F5496004DFAD7 /* PSCLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSCLogging.h; sourceTree = ""; }; + A9022B942564311C00C7CC3B /* tmp.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = tmp.xcconfig; sourceTree = ""; }; A96C0B40238A0B8300BF7682 /* PSCCoreData.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = PSCCoreData.podspec; sourceTree = ""; }; A9BD92851FF15E9900F4B027 /* PSCCoreData.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PSCCoreData.framework; sourceTree = BUILT_PRODUCTS_DIR; }; A9BD92871FF15E9900F4B027 /* PSCCoreData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSCCoreData.h; sourceTree = ""; }; @@ -102,6 +103,7 @@ 9B5FDB0D16FC65AB002FA5A6 = { isa = PBXGroup; children = ( + A9022B942564311C00C7CC3B /* tmp.xcconfig */, A96C0B40238A0B8300BF7682 /* PSCCoreData.podspec */, 9B5FDB1B16FC65AB002FA5A6 /* PSCCoreDataStack */, A9BD92861FF15E9900F4B027 /* PSCCoreData */, @@ -333,6 +335,7 @@ /* Begin XCBuildConfiguration section */ 9B5FDB3916FC65AC002FA5A6 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = A9022B942564311C00C7CC3B /* tmp.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -372,7 +375,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; @@ -380,6 +383,7 @@ }; 9B5FDB3A16FC65AC002FA5A6 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = A9022B942564311C00C7CC3B /* tmp.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -411,7 +415,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; diff --git a/tmp.xcconfig b/tmp.xcconfig new file mode 100644 index 0000000..5f89f79 --- /dev/null +++ b/tmp.xcconfig @@ -0,0 +1,2 @@ +EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64=arm64 arm64e armv7 armv7s armv6 armv8 +EXCLUDED_ARCHS=$(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)) From a5c872c1c09f6a0d33672c80ea7fc49058ef7e8f Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Mon, 15 Feb 2021 01:18:51 +0100 Subject: [PATCH 35/40] removed tmp.xcconfig since XCFrameworks is used now --- PSCCoreDataStack.xcodeproj/project.pbxproj | 4 ---- tmp.xcconfig | 2 -- 2 files changed, 6 deletions(-) delete mode 100644 tmp.xcconfig diff --git a/PSCCoreDataStack.xcodeproj/project.pbxproj b/PSCCoreDataStack.xcodeproj/project.pbxproj index aa7d88f..6117194 100644 --- a/PSCCoreDataStack.xcodeproj/project.pbxproj +++ b/PSCCoreDataStack.xcodeproj/project.pbxproj @@ -70,7 +70,6 @@ 9B5FDB5816FC7025002FA5A6 /* PSCFetchedResultsControllerUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSCFetchedResultsControllerUpdater.m; sourceTree = ""; }; 9B5FDB5A16FC7387002FA5A6 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 9B6B3C56170F5496004DFAD7 /* PSCLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSCLogging.h; sourceTree = ""; }; - A9022B942564311C00C7CC3B /* tmp.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = tmp.xcconfig; sourceTree = ""; }; A96C0B40238A0B8300BF7682 /* PSCCoreData.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = PSCCoreData.podspec; sourceTree = ""; }; A9BD92851FF15E9900F4B027 /* PSCCoreData.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PSCCoreData.framework; sourceTree = BUILT_PRODUCTS_DIR; }; A9BD92871FF15E9900F4B027 /* PSCCoreData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSCCoreData.h; sourceTree = ""; }; @@ -103,7 +102,6 @@ 9B5FDB0D16FC65AB002FA5A6 = { isa = PBXGroup; children = ( - A9022B942564311C00C7CC3B /* tmp.xcconfig */, A96C0B40238A0B8300BF7682 /* PSCCoreData.podspec */, 9B5FDB1B16FC65AB002FA5A6 /* PSCCoreDataStack */, A9BD92861FF15E9900F4B027 /* PSCCoreData */, @@ -335,7 +333,6 @@ /* Begin XCBuildConfiguration section */ 9B5FDB3916FC65AC002FA5A6 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A9022B942564311C00C7CC3B /* tmp.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -383,7 +380,6 @@ }; 9B5FDB3A16FC65AC002FA5A6 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = A9022B942564311C00C7CC3B /* tmp.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; diff --git a/tmp.xcconfig b/tmp.xcconfig deleted file mode 100644 index 5f89f79..0000000 --- a/tmp.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64=arm64 arm64e armv7 armv7s armv6 armv8 -EXCLUDED_ARCHS=$(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)) From 7bc605c9e0c35ab63ed98e906990d4862be8fd2d Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Fri, 17 Sep 2021 20:48:21 +0200 Subject: [PATCH 36/40] Fixed threading issue --- PSCCoreData.podspec | 4 +-- PSCCoreData/Info.plist | 2 +- ...NSManagedObjectContext+PSCCoreDataHelper.m | 32 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/PSCCoreData.podspec b/PSCCoreData.podspec index 5ade889..ab18905 100644 --- a/PSCCoreData.podspec +++ b/PSCCoreData.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.platform = :ios, '11.0' s.ios.deployment_target = '11.0' s.name = "PSCCoreData" - s.version = "1.0.9" + s.version = "1.0.11" s.license = 'MIT' s.summary = "Helper for managing the CoreData Stack." s.homepage = "https://github.com/PocketScientists/PSCCoreDataStack.git" @@ -12,7 +12,7 @@ Pod::Spec.new do |s| 'Jürgen Falb' => 'j.falb@nousdigital.net', 'Philip Messlehner' => 'p.messlehner@pocketscience.com' } - s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.9' } + s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.11' } s.source_files = 'PSCCoreDataStack/*.{h,m}', 'PSCCoreData/PSCCoreData.h' s.public_header_files = 'PSCCoreDataStack/*.{h}', 'PSCCoreData/PSCCoreData.h' diff --git a/PSCCoreData/Info.plist b/PSCCoreData/Info.plist index e234e4b..a2cf988 100644 --- a/PSCCoreData/Info.plist +++ b/PSCCoreData/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.3 + 1.0.11 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m index 297cff8..4408764 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m @@ -35,28 +35,28 @@ - (void)saveAndPropagateToParentContextBlocking:(BOOL)wait error:(__autoreleasin } }; - if (self.hasChanges) { - if (self.concurrencyType == NSConfinementConcurrencyType) { - if ([self save:error]) { - parentCheck(); - } - } else if (wait) { - [self performBlockAndWait:^{ + if (wait) { + [self performBlockAndWait:^{ + if (self.hasChanges) { if ([self save:error]) { parentCheck(); } - }]; - } - else { - [self performBlock:^{ + } + else { + parentCheck(); + } + }]; + } else { + [self performBlock:^{ + if (self.hasChanges) { if ([self save:error]) { parentCheck(); } - }]; - } - } - else { - parentCheck(); + } + else { + parentCheck(); + } + }]; } } From b6529ffff149d589c0becc0f92190474799da0fd Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Fri, 17 Sep 2021 20:49:05 +0200 Subject: [PATCH 37/40] Bumped version to 1.0.12 --- PSCCoreData.podspec | 4 ++-- PSCCoreData/Info.plist | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PSCCoreData.podspec b/PSCCoreData.podspec index ab18905..8ad65eb 100644 --- a/PSCCoreData.podspec +++ b/PSCCoreData.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.platform = :ios, '11.0' s.ios.deployment_target = '11.0' s.name = "PSCCoreData" - s.version = "1.0.11" + s.version = "1.0.12" s.license = 'MIT' s.summary = "Helper for managing the CoreData Stack." s.homepage = "https://github.com/PocketScientists/PSCCoreDataStack.git" @@ -12,7 +12,7 @@ Pod::Spec.new do |s| 'Jürgen Falb' => 'j.falb@nousdigital.net', 'Philip Messlehner' => 'p.messlehner@pocketscience.com' } - s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.11' } + s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.12' } s.source_files = 'PSCCoreDataStack/*.{h,m}', 'PSCCoreData/PSCCoreData.h' s.public_header_files = 'PSCCoreDataStack/*.{h}', 'PSCCoreData/PSCCoreData.h' diff --git a/PSCCoreData/Info.plist b/PSCCoreData/Info.plist index a2cf988..1b8eb83 100644 --- a/PSCCoreData/Info.plist +++ b/PSCCoreData/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.11 + 1.0.12 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass From 5d5b4648950c7f8e6c5009166d617e4c49ad2ecc Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Fri, 17 Sep 2021 20:56:23 +0200 Subject: [PATCH 38/40] Fixed threading issue --- PSCCoreData.podspec | 4 +- PSCCoreData/Info.plist | 2 +- ...NSManagedObjectContext+PSCCoreDataHelper.m | 43 +++++++++++-------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/PSCCoreData.podspec b/PSCCoreData.podspec index 8ad65eb..7bcf077 100644 --- a/PSCCoreData.podspec +++ b/PSCCoreData.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.platform = :ios, '11.0' s.ios.deployment_target = '11.0' s.name = "PSCCoreData" - s.version = "1.0.12" + s.version = "1.0.13" s.license = 'MIT' s.summary = "Helper for managing the CoreData Stack." s.homepage = "https://github.com/PocketScientists/PSCCoreDataStack.git" @@ -12,7 +12,7 @@ Pod::Spec.new do |s| 'Jürgen Falb' => 'j.falb@nousdigital.net', 'Philip Messlehner' => 'p.messlehner@pocketscience.com' } - s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.12' } + s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.13' } s.source_files = 'PSCCoreDataStack/*.{h,m}', 'PSCCoreData/PSCCoreData.h' s.public_header_files = 'PSCCoreDataStack/*.{h}', 'PSCCoreData/PSCCoreData.h' diff --git a/PSCCoreData/Info.plist b/PSCCoreData/Info.plist index 1b8eb83..3235e97 100644 --- a/PSCCoreData/Info.plist +++ b/PSCCoreData/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.12 + 1.0.13 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m index 4408764..b0d8f6f 100644 --- a/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m +++ b/PSCCoreDataStack/NSManagedObjectContext+PSCCoreDataHelper.m @@ -88,27 +88,36 @@ - (void)saveAndPropagateToParentContextBlocking:(BOOL)wait success:(void(^)(void } }; - if (self.hasChanges) { - dispatch_block_t saveChild = ^{ - NSError *error = nil; - if ([self save:&error]) { + dispatch_block_t saveChild = ^{ + NSError *error = nil; + if ([self save:&error]) { + parentCheck(); + } + else { + if (failureBlock) { + failureBlock(error); + } + } + }; + + if (wait) { + [self performBlockAndWait:^{ + if (self.hasChanges) { + saveChild(); + } + else { parentCheck(); } + }]; + } else { + [self performBlock:^{ + if (self.hasChanges) { + saveChild(); + } else { - if (failureBlock) { - failureBlock(error); - } + parentCheck(); } - }; - - if (wait) { - [self performBlockAndWait:saveChild]; - } else { - [self performBlock:saveChild]; - } - } - else { - parentCheck(); + }]; } } From 1c90e0a8c710795cef80240b54d334b5d991945a Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Sun, 19 Sep 2021 09:52:35 +0200 Subject: [PATCH 39/40] Fixed threading issue --- PSCCoreData.podspec | 4 ++-- PSCCoreData/Info.plist | 2 +- PSCCoreDataStack/PSCPersistenceOperation.m | 22 ++++++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/PSCCoreData.podspec b/PSCCoreData.podspec index 7bcf077..799c9c1 100644 --- a/PSCCoreData.podspec +++ b/PSCCoreData.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.platform = :ios, '11.0' s.ios.deployment_target = '11.0' s.name = "PSCCoreData" - s.version = "1.0.13" + s.version = "1.0.14" s.license = 'MIT' s.summary = "Helper for managing the CoreData Stack." s.homepage = "https://github.com/PocketScientists/PSCCoreDataStack.git" @@ -12,7 +12,7 @@ Pod::Spec.new do |s| 'Jürgen Falb' => 'j.falb@nousdigital.net', 'Philip Messlehner' => 'p.messlehner@pocketscience.com' } - s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.13' } + s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.14' } s.source_files = 'PSCCoreDataStack/*.{h,m}', 'PSCCoreData/PSCCoreData.h' s.public_header_files = 'PSCCoreDataStack/*.{h}', 'PSCCoreData/PSCCoreData.h' diff --git a/PSCCoreData/Info.plist b/PSCCoreData/Info.plist index 3235e97..b84a849 100644 --- a/PSCCoreData/Info.plist +++ b/PSCCoreData/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.13 + 1.0.14 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/PSCCoreDataStack/PSCPersistenceOperation.m b/PSCCoreDataStack/PSCPersistenceOperation.m index 1d1c096..3183f4a 100644 --- a/PSCCoreDataStack/PSCPersistenceOperation.m +++ b/PSCCoreDataStack/PSCPersistenceOperation.m @@ -44,19 +44,21 @@ + (void)persistDataInBackgroundWithParentContext:(NSManagedObjectContext *)paren dispatch_async(psc_persistence_queue(), ^{ NSManagedObjectContext *localContext = [parentContext newChildContextWithConcurrencyType:NSPrivateQueueConcurrencyType]; - NSError *error = nil; - if (block != nil) { - block(localContext); - } + [localContext performBlock:^{ + if (block != nil) { + block(localContext); + } - if (![localContext save:&error]) { - PSCCDLog(@"Error persisting local context in PSCPersistenceAction: %@", error); - } + NSError *error = nil; + if (![localContext save:&error]) { + PSCCDLog(@"Error persisting local context in PSCPersistenceAction: %@", error); + } - if (completion != nil) { - dispatch_async(dispatch_get_main_queue(), completion); - } + if (completion != nil) { + dispatch_async(dispatch_get_main_queue(), completion); + } + }]; }); } From 4bbf26f2e108a4767731d4e9c0e3d7d3f0009a6b Mon Sep 17 00:00:00 2001 From: Juergen Falb Date: Sun, 19 Sep 2021 10:03:26 +0200 Subject: [PATCH 40/40] Fixed threading issue --- PSCCoreData.podspec | 4 +-- PSCCoreData/Info.plist | 2 +- PSCCoreDataStack/PSCPersistenceOperation.m | 42 +++++++++++----------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/PSCCoreData.podspec b/PSCCoreData.podspec index 799c9c1..99842e5 100644 --- a/PSCCoreData.podspec +++ b/PSCCoreData.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.platform = :ios, '11.0' s.ios.deployment_target = '11.0' s.name = "PSCCoreData" - s.version = "1.0.14" + s.version = "1.0.15" s.license = 'MIT' s.summary = "Helper for managing the CoreData Stack." s.homepage = "https://github.com/PocketScientists/PSCCoreDataStack.git" @@ -12,7 +12,7 @@ Pod::Spec.new do |s| 'Jürgen Falb' => 'j.falb@nousdigital.net', 'Philip Messlehner' => 'p.messlehner@pocketscience.com' } - s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.14' } + s.source = { :git => "https://github.com/PocketScientists/PSCCoreDataStack.git", :tag => '1.0.15' } s.source_files = 'PSCCoreDataStack/*.{h,m}', 'PSCCoreData/PSCCoreData.h' s.public_header_files = 'PSCCoreDataStack/*.{h}', 'PSCCoreData/PSCCoreData.h' diff --git a/PSCCoreData/Info.plist b/PSCCoreData/Info.plist index b84a849..910e827 100644 --- a/PSCCoreData/Info.plist +++ b/PSCCoreData/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.14 + 1.0.15 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass diff --git a/PSCCoreDataStack/PSCPersistenceOperation.m b/PSCCoreDataStack/PSCPersistenceOperation.m index 3183f4a..7c04f97 100644 --- a/PSCCoreDataStack/PSCPersistenceOperation.m +++ b/PSCCoreDataStack/PSCPersistenceOperation.m @@ -93,28 +93,30 @@ - (void)didNotSaveContext:(NSManagedObjectContext *)localContext { - (void)main { NSManagedObjectContext *localContext = [self.parentContext newChildContextWithConcurrencyType:NSPrivateQueueConcurrencyType]; - BOOL save = NO; - - // either persist via block (if set), or call method in subclass - if (self.persistenceBlock != nil) { - save = self.persistenceBlock(localContext); - } else { - save = [self persistWithContext:localContext]; - } - - if (save && localContext.hasChanges) { - NSError *error = nil; - - [self willSaveContext:localContext]; - - if (![localContext save:&error]) { - [self didFailToSaveContext:localContext error:error]; + [localContext performBlock:^{ + BOOL save = NO; + + // either persist via block (if set), or call method in subclass + if (self.persistenceBlock != nil) { + save = self.persistenceBlock(localContext); + } else { + save = [self persistWithContext:localContext]; + } + + if (save && localContext.hasChanges) { + NSError *error = nil; + + [self willSaveContext:localContext]; + + if (![localContext save:&error]) { + [self didFailToSaveContext:localContext error:error]; + } else { + [self didSaveContext:localContext]; + } } else { - [self didSaveContext:localContext]; + [self didNotSaveContext:localContext]; } - } else { - [self didNotSaveContext:localContext]; - } + }]; } ////////////////////////////////////////////////////////////////////////