mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 10:21:17 +01:00
Merge branch 'develop' into swift3_develop
# Conflicts: # Cartfile # Carthage/Checkouts/GCDKit # CoreStore.podspec # CoreStore.xcodeproj/project.pbxproj # CoreStoreDemo/CoreStoreDemo.xcodeproj/project.pbxproj # CoreStoreTests/BaseTests/BaseTestCase.swift # CoreStoreTests/FromTests.swift # CoreStoreTests/GroupByTests.swift # CoreStoreTests/OrderByTests.swift # CoreStoreTests/StorageInterfaceTests.swift # CoreStoreTests/TweakTests.swift # CoreStoreTests/WhereTests.swift # README.md # Sources/Internal/CoreStoreFetchRequest.swift # Sources/Internal/NSManagedObjectContext+Querying.swift # Sources/Internal/NSManagedObjectModel+Setup.swift # Sources/Migrating/DataStack+Migration.swift # Sources/ObjectiveC/CSSQliteStore.swift # Sources/ObjectiveC/CSStorageInterface.swift # Sources/ObjectiveC/CoreStoreBridge.swift # Sources/Observing/ListMonitor.swift # Sources/Setup/DataStack.swift # Sources/Setup/StorageInterfaces/ICloudStore.swift # Sources/Setup/StorageInterfaces/LegacySQLiteStore.swift # Sources/Setup/StorageInterfaces/SQLiteStore.swift # Sources/Setup/StorageInterfaces/StorageInterface.swift
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.4</string>
|
||||
<string>2.1.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
|
||||
@@ -132,6 +132,16 @@ internal final class FetchedResultsControllerDelegate<EntityType: NSManagedObjec
|
||||
}
|
||||
}
|
||||
|
||||
if #available(iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
|
||||
|
||||
// I don't know if iOS 10 even attempted to fix this mess...
|
||||
if case .update = actualType,
|
||||
indexPath != nil && newIndexPath != nil {
|
||||
|
||||
actualType = .move
|
||||
}
|
||||
}
|
||||
|
||||
switch actualType {
|
||||
|
||||
case .update:
|
||||
@@ -141,8 +151,8 @@ internal final class FetchedResultsControllerDelegate<EntityType: NSManagedObjec
|
||||
}
|
||||
if self.deletedSections.contains(section)
|
||||
|| self.insertedSections.contains(section) {
|
||||
|
||||
return
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case .move:
|
||||
|
||||
@@ -143,7 +143,7 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
// MARK: CoreStoreObjectiveCType
|
||||
|
||||
internal typealias SwiftType = AsynchronousDataTransaction
|
||||
public typealias SwiftType = AsynchronousDataTransaction
|
||||
|
||||
public override var bridgeToSwift: AsynchronousDataTransaction {
|
||||
|
||||
@@ -152,21 +152,21 @@ public final class CSAsynchronousDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
public required init(_ swiftValue: AsynchronousDataTransaction) {
|
||||
|
||||
super.init(swiftValue)
|
||||
super.init(swiftValue as BaseDataTransaction)
|
||||
}
|
||||
|
||||
public required init(_ swiftValue: BaseDataTransaction) {
|
||||
|
||||
fatalError("init(_:) requires an AsynchronousDataTransaction instance")
|
||||
super.init(swiftValue as! AsynchronousDataTransaction)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - AsynchronousDataTransaction
|
||||
|
||||
extension AsynchronousDataTransaction {
|
||||
extension AsynchronousDataTransaction: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
internal typealias ObjectiveCType = CSAsynchronousDataTransaction
|
||||
public typealias ObjectiveCType = CSAsynchronousDataTransaction
|
||||
}
|
||||
|
||||
@@ -278,8 +278,6 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
|
||||
// MARK: CoreStoreObjectiveCType
|
||||
|
||||
public typealias SwiftType = BaseDataTransaction
|
||||
|
||||
public required init(_ swiftValue: BaseDataTransaction) {
|
||||
|
||||
self.swiftTransaction = swiftValue
|
||||
@@ -298,11 +296,11 @@ public class CSBaseDataTransaction: NSObject, CoreStoreObjectiveCType {
|
||||
}
|
||||
|
||||
|
||||
// MARK: - BaseDataTransaction
|
||||
|
||||
extension BaseDataTransaction: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
public typealias ObjectiveCType = CSBaseDataTransaction
|
||||
}
|
||||
//// MARK: - BaseDataTransaction
|
||||
//
|
||||
//extension BaseDataTransaction: CoreStoreSwiftType {
|
||||
//
|
||||
// // MARK: CoreStoreSwiftType
|
||||
//
|
||||
// public typealias ObjectiveCType = CSBaseDataTransaction
|
||||
//}
|
||||
|
||||
@@ -142,7 +142,7 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
// MARK: CoreStoreObjectiveCType
|
||||
|
||||
internal typealias SwiftType = SynchronousDataTransaction
|
||||
public typealias SwiftType = SynchronousDataTransaction
|
||||
|
||||
public override var bridgeToSwift: SynchronousDataTransaction {
|
||||
|
||||
@@ -151,21 +151,21 @@ public final class CSSynchronousDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
public required init(_ swiftValue: SynchronousDataTransaction) {
|
||||
|
||||
super.init(swiftValue)
|
||||
super.init(swiftValue as BaseDataTransaction)
|
||||
}
|
||||
|
||||
public required init(_ swiftValue: BaseDataTransaction) {
|
||||
|
||||
fatalError("init(_:) requires a BaseDataTransaction instance")
|
||||
super.init(swiftValue as! SynchronousDataTransaction)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - SynchronousDataTransaction
|
||||
|
||||
extension SynchronousDataTransaction {
|
||||
extension SynchronousDataTransaction: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
internal typealias ObjectiveCType = CSSynchronousDataTransaction
|
||||
public typealias ObjectiveCType = CSSynchronousDataTransaction
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
// MARK: CoreStoreObjectiveCType
|
||||
|
||||
internal typealias SwiftType = UnsafeDataTransaction
|
||||
public typealias SwiftType = UnsafeDataTransaction
|
||||
|
||||
public override var bridgeToSwift: UnsafeDataTransaction {
|
||||
|
||||
@@ -181,21 +181,21 @@ public final class CSUnsafeDataTransaction: CSBaseDataTransaction {
|
||||
|
||||
public required init(_ swiftValue: UnsafeDataTransaction) {
|
||||
|
||||
super.init(swiftValue)
|
||||
super.init(swiftValue as BaseDataTransaction)
|
||||
}
|
||||
|
||||
public required init(_ swiftValue: BaseDataTransaction) {
|
||||
|
||||
fatalError("init(_:) requires an UnsafeDataTransaction instance")
|
||||
super.init(swiftValue as! UnsafeDataTransaction)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: - UnsafeDataTransaction
|
||||
|
||||
extension UnsafeDataTransaction {
|
||||
extension UnsafeDataTransaction: CoreStoreSwiftType {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
internal typealias ObjectiveCType = CSUnsafeDataTransaction
|
||||
public typealias ObjectiveCType = CSUnsafeDataTransaction
|
||||
}
|
||||
|
||||
@@ -570,4 +570,16 @@ CORESTORE_EXTERN
|
||||
CSWhere *_Nonnull CSWherePredicate(NSPredicate *_Nonnull predicate) CORESTORE_RETURNS_RETAINED;
|
||||
|
||||
|
||||
#pragma mark CoreStoreFetchRequest
|
||||
|
||||
// Bugfix for NSFetchRequest messing up memory management for `affectedStores`
|
||||
// http://stackoverflow.com/questions/14396375/nsfetchedresultscontroller-crashes-in-ios-6-if-affectedstores-is-specified
|
||||
NS_SWIFT_NAME(CoreStoreFetchRequest)
|
||||
@interface _CSFetchRequest: NSFetchRequest
|
||||
|
||||
@property (nullable, nonatomic, copy, readonly) NSArray<NSPersistentStore *> *safeAffectedStores;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#endif /* CoreStoreBridge_h */
|
||||
|
||||
@@ -26,23 +26,8 @@
|
||||
|
||||
#import "CoreStoreBridge.h"
|
||||
|
||||
#if USE_FRAMEWORKS
|
||||
#import <CoreStore/CoreStore-Swift.h>
|
||||
|
||||
#elif !defined(SWIFT_OBJC_INTERFACE_HEADER_NAME)
|
||||
#error Add "SWIFT_OBJC_INTERFACE_HEADER_NAME=$(SWIFT_OBJC_INTERFACE_HEADER_NAME)" to the project's GCC_PREPROCESSOR_DEFINITIONS settings
|
||||
|
||||
#elif __has_include(SWIFT_OBJC_INTERFACE_HEADER_NAME)
|
||||
#import SWIFT_OBJC_INTERFACE_HEADER_NAME
|
||||
|
||||
#else
|
||||
#define _STRINGIFY(x) #x
|
||||
#define STRINGIFY(x) _STRINGIFY(x)
|
||||
#import STRINGIFY(SWIFT_OBJC_INTERFACE_HEADER_NAME)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#pragma mark - Clauses
|
||||
|
||||
@@ -233,3 +218,40 @@ CSWhere *_Nonnull CSWherePredicate(NSPredicate *_Nonnull predicate) CORESTORE_RE
|
||||
|
||||
return [[CSWhere alloc] initWithPredicate:predicate];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark CoreStoreFetchRequest
|
||||
|
||||
@interface _CSFetchRequest ()
|
||||
|
||||
@property (nullable, nonatomic, copy) NSArray<NSPersistentStore *> *safeAffectedStores;
|
||||
@property (nullable, nonatomic, assign) CFArrayRef releaseArray;
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CSFetchRequest
|
||||
|
||||
// MARK: NSFetchRequest
|
||||
|
||||
- (void)setAffectedStores:(NSArray<NSPersistentStore *> *_Nullable)affectedStores {
|
||||
|
||||
// Bugfix for NSFetchRequest messing up memory management for `affectedStores`
|
||||
// http://stackoverflow.com/questions/14396375/nsfetchedresultscontroller-crashes-in-ios-6-if-affectedstores-is-specified
|
||||
|
||||
if (NSFoundationVersionNumber < NSFoundationVersionNumber10_0) {
|
||||
|
||||
self.safeAffectedStores = affectedStores;
|
||||
[super setAffectedStores:affectedStores];
|
||||
return;
|
||||
}
|
||||
if (self.releaseArray != NULL) {
|
||||
|
||||
CFRelease(self.releaseArray);
|
||||
self.releaseArray = NULL;
|
||||
}
|
||||
self.safeAffectedStores = affectedStores;
|
||||
[super setAffectedStores:affectedStores];
|
||||
self.releaseArray = CFBridgingRetain([super affectedStores]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1068,7 +1068,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
self.isPersistentStoreChanging = true
|
||||
|
||||
guard let removedStores = (note.userInfo?[NSRemovedPersistentStoresKey] as? [NSPersistentStore]).flatMap(Set.init),
|
||||
!Set(self.fetchedResultsController.fetchRequest.affectedStores ?? []).intersection(removedStores).isEmpty else {
|
||||
!Set((self.fetchedResultsController.fetchRequest as! CoreStoreFetchRequest).affectedStores ?? []).intersection(removedStores).isEmpty else {
|
||||
|
||||
return
|
||||
}
|
||||
@@ -1089,7 +1089,7 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
|
||||
|
||||
if !self.isPendingRefetch {
|
||||
|
||||
let previousStores = Set(self.fetchedResultsController.fetchRequest.affectedStores ?? [])
|
||||
let previousStores = Set((self.fetchedResultsController.fetchRequest as! CoreStoreFetchRequest).safeAffectedStores ?? [])
|
||||
let currentStores = previousStores
|
||||
.subtracting(note.userInfo?[NSRemovedPersistentStoresKey] as? [NSPersistentStore] ?? [])
|
||||
.union(note.userInfo?[NSAddedPersistentStoresKey] as? [NSPersistentStore] ?? [])
|
||||
|
||||
Reference in New Issue
Block a user