mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 21:23:43 +01:00
Cleanup unnecessary #available branches
This commit is contained in:
@@ -3372,7 +3372,7 @@
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
TVOS_DEPLOYMENT_TARGET = 10.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 11.0;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
WATCHOS_DEPLOYMENT_TARGET = 3.0;
|
||||
@@ -3436,7 +3436,7 @@
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
TVOS_DEPLOYMENT_TARGET = 10.0;
|
||||
TVOS_DEPLOYMENT_TARGET = 11.0;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
|
||||
@@ -191,16 +191,8 @@
|
||||
XCTAssertEqualObjects([[sqliteStorage class] storeType], [CSSQLiteStore storeType]);
|
||||
XCTAssertEqualObjects([[sqliteStorage class] storeType], NSSQLiteStoreType);
|
||||
XCTAssertNil(sqliteStorage.configuration);
|
||||
NSDictionary *storeOptions;
|
||||
if (@available(iOS 11.0, macOS 10.13, tvOS 11.0, *)) {
|
||||
|
||||
storeOptions = @{ NSSQLitePragmasOption: @{ @"journal_mode": @"WAL" },
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: @YES };
|
||||
}
|
||||
else {
|
||||
|
||||
storeOptions = @{ NSSQLitePragmasOption: @{ @"journal_mode": @"WAL" }};
|
||||
}
|
||||
NSDictionary *storeOptions = @{ NSSQLitePragmasOption: @{ @"journal_mode": @"WAL" },
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: @YES };
|
||||
XCTAssertEqualObjects(sqliteStorage.storeOptions, storeOptions);
|
||||
XCTAssertNil(sqliteError);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import CoreStore
|
||||
|
||||
// MARK: - ConvenienceTests
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
class ConvenienceTests: BaseTestCase {
|
||||
|
||||
@objc
|
||||
|
||||
@@ -31,7 +31,6 @@ import CoreStore
|
||||
|
||||
// MARK: - ListObserverTests
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
class ListObserverTests: BaseTestDataTestCase {
|
||||
|
||||
@objc
|
||||
@@ -551,7 +550,6 @@ class ListObserverTests: BaseTestDataTestCase {
|
||||
|
||||
// MARK: TestListObserver
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
class TestListObserver: ListSectionObserver {
|
||||
|
||||
// MARK: ListObserver
|
||||
|
||||
@@ -31,7 +31,6 @@ import CoreStore
|
||||
|
||||
// MARK: - ObjectObserverTests
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
class ObjectObserverTests: BaseTestDataTestCase {
|
||||
|
||||
@objc
|
||||
@@ -203,7 +202,6 @@ class ObjectObserverTests: BaseTestDataTestCase {
|
||||
|
||||
// MARK: TestObjectObserver
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
class TestObjectObserver: ObjectObserver {
|
||||
|
||||
typealias ObjectEntityType = TestEntity1
|
||||
|
||||
@@ -31,7 +31,6 @@ import CoreStore
|
||||
|
||||
// MARK: - ObjectPublisherTests
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
class ObjectPublisherTests: BaseTestDataTestCase {
|
||||
|
||||
@objc
|
||||
|
||||
@@ -31,7 +31,6 @@ import CoreStore
|
||||
|
||||
//MARK: - SectionByTests
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
final class SectionByTests: XCTestCase {
|
||||
|
||||
@objc
|
||||
|
||||
@@ -83,21 +83,11 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
let store = SQLiteStore()
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertNil(store.configuration)
|
||||
if #available(iOS 11.0, macOS 10.13, tvOS 11.0, *) {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary
|
||||
)
|
||||
}
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
|
||||
XCTAssertEqual(store.fileURL, SQLiteStore.defaultFileURL)
|
||||
XCTAssertTrue(store.migrationMappingProviders.isEmpty)
|
||||
@@ -123,21 +113,11 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
)
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(store.configuration, "config1")
|
||||
if #available(iOS 11.0, macOS 10.13, tvOS 11.0, *) {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary
|
||||
)
|
||||
}
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
|
||||
XCTAssertEqual(store.fileURL, fileURL)
|
||||
XCTAssertEqual(store.migrationMappingProviders as! [XcodeSchemaMappingProvider], [mappingProvider])
|
||||
@@ -160,21 +140,11 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
)
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(store.configuration, "config1")
|
||||
if #available(iOS 11.0, macOS 10.13, tvOS 11.0, *) {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary
|
||||
)
|
||||
}
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
|
||||
XCTAssertEqual(store.fileURL.deletingLastPathComponent(), SQLiteStore.defaultRootDirectory)
|
||||
XCTAssertEqual(store.fileURL.lastPathComponent, fileName)
|
||||
@@ -209,21 +179,11 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
let store = SQLiteStore.legacy()
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertNil(store.configuration)
|
||||
if #available(iOS 11.0, macOS 10.13, tvOS 11.0, *) {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary
|
||||
)
|
||||
}
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
|
||||
XCTAssertEqual(store.fileURL, SQLiteStore.legacyDefaultFileURL)
|
||||
XCTAssertTrue(store.migrationMappingProviders.isEmpty)
|
||||
@@ -246,21 +206,11 @@ final class StorageInterfaceTests: XCTestCase {
|
||||
)
|
||||
XCTAssertEqual(type(of: store).storeType, NSSQLiteStoreType)
|
||||
XCTAssertEqual(store.configuration, "config1")
|
||||
if #available(iOS 11.0, macOS 10.13, tvOS 11.0, *) {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]] as NSDictionary
|
||||
)
|
||||
}
|
||||
XCTAssertEqual(
|
||||
store.storeOptions as NSDictionary?,
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true] as NSDictionary
|
||||
)
|
||||
|
||||
XCTAssertEqual(store.fileURL.deletingLastPathComponent(), SQLiteStore.legacyDefaultRootDirectory)
|
||||
XCTAssertEqual(store.fileURL.lastPathComponent, fileName)
|
||||
|
||||
@@ -383,8 +383,6 @@ final class TransactionTests: BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
@objc
|
||||
dynamic func test_ThatSynchronousTransactions_CanCommitWithoutWaitingForMerges() {
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import CoreData
|
||||
// MARK: - CSDataStack
|
||||
|
||||
@available(*, deprecated, message: "CoreStore Objective-C API will be removed soon.")
|
||||
@available(macOS 10.12, *)
|
||||
extension CSDataStack {
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,6 @@ import CoreData
|
||||
|
||||
- SeeAlso: `ListMonitor`
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
@objc
|
||||
public final class CSListMonitor: NSObject {
|
||||
|
||||
@@ -546,7 +545,6 @@ public final class CSListMonitor: NSObject {
|
||||
|
||||
// MARK: - ListMonitor
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ListMonitor where ListMonitor.ObjectType: NSManagedObject {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
@@ -40,7 +40,6 @@ import CoreData
|
||||
|
||||
- SeeAlso: `ListObserver`
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
@objc
|
||||
public protocol CSListObserver: AnyObject {
|
||||
|
||||
@@ -91,7 +90,6 @@ public protocol CSListObserver: AnyObject {
|
||||
|
||||
- SeeAlso: `ListObjectObserver`
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
@objc
|
||||
public protocol CSListObjectObserver: CSListObserver {
|
||||
|
||||
@@ -152,7 +150,6 @@ public protocol CSListObjectObserver: CSListObserver {
|
||||
|
||||
- SeeAlso: `ListSectionObserver`
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
@objc
|
||||
public protocol CSListSectionObserver: CSListObjectObserver {
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import CoreData
|
||||
|
||||
- SeeAlso: `ObjectMonitor`
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
@objc
|
||||
public final class CSObjectMonitor: NSObject {
|
||||
|
||||
@@ -139,7 +138,6 @@ public final class CSObjectMonitor: NSObject {
|
||||
|
||||
// MARK: - ObjectMonitor
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ObjectMonitor where ObjectMonitor.ObjectType: NSManagedObject {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
@@ -38,7 +38,6 @@ import CoreData
|
||||
|
||||
- SeeAlso: `ObjectObserver`
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
@objc
|
||||
public protocol CSObjectObserver: AnyObject {
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import CoreData
|
||||
|
||||
- SeeAlso: `SectionBy`
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
@objc
|
||||
public final class CSSectionBy: NSObject {
|
||||
|
||||
@@ -91,7 +90,6 @@ public final class CSSectionBy: NSObject {
|
||||
|
||||
// MARK: - SectionBy
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension SectionBy {
|
||||
|
||||
// MARK: CoreStoreSwiftType
|
||||
|
||||
@@ -359,7 +359,6 @@ extension UnsafeDataModelSchema: CustomDebugStringConvertible, CoreStoreDebugStr
|
||||
|
||||
// MARK: - ListMonitor
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
fileprivate struct CoreStoreFetchedSectionInfoWrapper: CoreStoreDebugStringConvertible {
|
||||
|
||||
// MARK: CustomDebugStringConvertible
|
||||
@@ -404,7 +403,6 @@ fileprivate struct CoreStoreFetchedSectionInfoWrapper: CoreStoreDebugStringConve
|
||||
private let numberOfObjects: Int
|
||||
}
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ListMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
||||
|
||||
// MARK: CustomDebugStringConvertible
|
||||
@@ -431,7 +429,6 @@ extension ListMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvert
|
||||
|
||||
// MARK: - ListPublisher
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ListPublisher: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
||||
|
||||
// MARK: CustomDebugStringConvertible
|
||||
@@ -614,7 +611,6 @@ extension MigrationType: CoreStoreDebugStringConvertible {
|
||||
|
||||
// MARK: - ObjectMonitor
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ObjectMonitor: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
||||
|
||||
// MARK: CustomDebugStringConvertible
|
||||
@@ -738,7 +734,6 @@ extension PartialObject: CustomDebugStringConvertible, CoreStoreDebugStringConve
|
||||
|
||||
// MARK: - SectionBy
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension SectionBy: CustomDebugStringConvertible, CoreStoreDebugStringConvertible {
|
||||
|
||||
// MARK: CustomDebugStringConvertible
|
||||
@@ -1259,33 +1254,20 @@ extension NSEntityDescription: CoreStoreDebugStringConvertible {
|
||||
|
||||
public var coreStoreDumpString: String {
|
||||
|
||||
var info: DumpInfo = [
|
||||
return createFormattedString(
|
||||
"(", ")",
|
||||
("managedObjectClassName", self.managedObjectClassName!),
|
||||
("name", self.name as Any),
|
||||
("indexes", self.indexes),
|
||||
("isAbstract", self.isAbstract),
|
||||
("superentity?.name", self.superentity?.name as Any),
|
||||
("subentities", self.subentities.map({ $0.name })),
|
||||
("properties", self.properties),
|
||||
("uniquenessConstraints", self.uniquenessConstraints),
|
||||
("userInfo", self.userInfo as Any),
|
||||
("versionHash", self.versionHash),
|
||||
("versionHashModifier", self.versionHashModifier as Any),
|
||||
("renamingIdentifier", self.renamingIdentifier as Any)
|
||||
]
|
||||
if #available(iOS 11.0, macOS 10.13, watchOS 4.0, tvOS 11.0, *) {
|
||||
|
||||
info.append(("indexes", self.indexes))
|
||||
}
|
||||
else {
|
||||
|
||||
info.append(("compoundIndexes", self.compoundIndexes))
|
||||
}
|
||||
if #available(macOS 10.11, iOS 9.0, *) {
|
||||
|
||||
info.append(("uniquenessConstraints", self.uniquenessConstraints))
|
||||
}
|
||||
return createFormattedString(
|
||||
"(", ")",
|
||||
info
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,18 +564,14 @@ public final class CoreStoreSchema: DynamicSchema {
|
||||
)
|
||||
}
|
||||
for (entity, entityDescription) in entityDescriptionsByEntity {
|
||||
|
||||
if entity.uniqueConstraints.contains(where: { !$0.isEmpty }) {
|
||||
|
||||
if #available(macOS 10.11, iOS 9.0, *) {
|
||||
|
||||
let uniqueConstraints = entity.uniqueConstraints.filter({ !$0.isEmpty })
|
||||
if !uniqueConstraints.isEmpty {
|
||||
|
||||
Internals.assert(
|
||||
entityDescription.superentity == nil,
|
||||
"Uniqueness constraints must be defined at the highest level possible."
|
||||
)
|
||||
entityDescription.uniquenessConstraints = entity.uniqueConstraints.map { $0.map { $0 as NSString } }
|
||||
}
|
||||
Internals.assert(
|
||||
entityDescription.superentity == nil,
|
||||
"Uniqueness constraints must be defined at the highest level possible."
|
||||
)
|
||||
entityDescription.uniquenessConstraints = entity.uniqueConstraints.map { $0.map { $0 as NSString } }
|
||||
}
|
||||
guard !entity.indexes.isEmpty else {
|
||||
|
||||
@@ -586,31 +582,18 @@ public final class CoreStoreSchema: DynamicSchema {
|
||||
entityDescription.coreStoreEntity = entity // reserialize
|
||||
}
|
||||
let attributesByName = entityDescription.attributesByName
|
||||
if #available(iOS 11.0, macOS 10.13, watchOS 4.0, tvOS 11.0, *) {
|
||||
entityDescription.indexes = entity.indexes.map { (compoundIndexes) in
|
||||
|
||||
entityDescription.indexes = entity.indexes.map { (compoundIndexes) in
|
||||
|
||||
return NSFetchIndexDescription.init(
|
||||
name: "_CoreStoreSchema_indexes_\(entityDescription.name!)_\(compoundIndexes.joined(separator: "-"))",
|
||||
elements: compoundIndexes.map { (keyPath) in
|
||||
|
||||
return NSFetchIndexElementDescription(
|
||||
property: attributesByName[keyPath]!,
|
||||
collationType: .binary
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
entityDescription.compoundIndexes = entity.indexes.map { (compoundIndexes) in
|
||||
|
||||
return compoundIndexes.map { (keyPath) in
|
||||
return NSFetchIndexDescription.init(
|
||||
name: "_CoreStoreSchema_indexes_\(entityDescription.name!)_\(compoundIndexes.joined(separator: "-"))",
|
||||
elements: compoundIndexes.map { (keyPath) in
|
||||
|
||||
return attributesByName[keyPath]!
|
||||
return NSFetchIndexElementDescription(
|
||||
property: attributesByName[keyPath]!,
|
||||
collationType: .binary
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -613,16 +613,7 @@ extension DataStack {
|
||||
}
|
||||
}
|
||||
let fileManager = FileManager.default
|
||||
let systemTemporaryDirectoryURL: URL
|
||||
if #available(macOS 10.12, iOS 10.0, *) {
|
||||
|
||||
systemTemporaryDirectoryURL = fileManager.temporaryDirectory
|
||||
}
|
||||
else {
|
||||
|
||||
systemTemporaryDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory())
|
||||
}
|
||||
let temporaryDirectoryURL = systemTemporaryDirectoryURL
|
||||
let temporaryDirectoryURL = fileManager.temporaryDirectory
|
||||
.appendingPathComponent(Bundle.main.bundleIdentifier ?? "com.CoreStore.DataStack")
|
||||
.appendingPathComponent(ProcessInfo().globallyUniqueString)
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import CoreData
|
||||
|
||||
// MARK: - DataStack
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension DataStack {
|
||||
|
||||
/**
|
||||
|
||||
@@ -247,16 +247,7 @@ extension DiffableDataSource {
|
||||
|
||||
return
|
||||
}
|
||||
if #available(iOS 11.0, tvOS 11.0, *) {
|
||||
|
||||
base.performBatchUpdates(updates)
|
||||
}
|
||||
else {
|
||||
|
||||
base.beginUpdates()
|
||||
updates()
|
||||
base.endUpdates()
|
||||
}
|
||||
base.performBatchUpdates(updates)
|
||||
}
|
||||
|
||||
public func reloadData() {
|
||||
|
||||
@@ -70,7 +70,6 @@ public final class Entity<O: CoreStoreObject>: DynamicEntity {
|
||||
- parameter indexes: the compound indexes for the entity as an array of arrays. The arrays contained in the returned array contain `KeyPath`s to properties of the entity.
|
||||
- parameter uniqueConstraints: sets uniqueness constraints for the entity. A uniqueness constraint is a set of one or more `KeyPath`s whose value must be unique over the set of instances of that entity. This value forms part of the entity's version hash. Uniqueness constraint violations can be computationally expensive to handle. It is highly suggested that there be only one uniqueness constraint per entity hierarchy. Uniqueness constraints must be defined at the highest level possible, and CoreStore will raise an assertion failure if unique constraints are added to a sub entity.
|
||||
*/
|
||||
@available(macOS 10.11, *)
|
||||
public convenience init(_ entityName: String, isAbstract: Bool = false, versionHashModifier: String? = nil, indexes: [[PartialKeyPath<O>]] = [], uniqueConstraints: [[PartialKeyPath<O>]]) {
|
||||
|
||||
self.init(
|
||||
@@ -116,7 +115,6 @@ public final class Entity<O: CoreStoreObject>: DynamicEntity {
|
||||
- parameter indexes: the compound indexes for the entity as an array of arrays. The arrays contained in the returned array contain KeyPath's to properties of the entity.
|
||||
- parameter uniqueConstraints: sets uniqueness constraints for the entity. A uniqueness constraint is a set of one or more `KeyPath`s whose value must be unique over the set of instances of that entity. This value forms part of the entity's version hash. Uniqueness constraint violations can be computationally expensive to handle. It is highly suggested that there be only one uniqueness constraint per entity hierarchy. Uniqueness constraints must be defined at the highest level possible, and CoreStore will raise an assertion failure if unique constraints are added to a sub entity.
|
||||
*/
|
||||
@available(macOS 10.11, *)
|
||||
public init(_ type: O.Type, _ entityName: String, isAbstract: Bool = false, versionHashModifier: String? = nil, indexes: [[PartialKeyPath<O>]] = [], uniqueConstraints: [[PartialKeyPath<O>]]) {
|
||||
|
||||
let meta = O.meta
|
||||
|
||||
@@ -47,17 +47,10 @@ extension FieldCoders {
|
||||
|
||||
return nil
|
||||
}
|
||||
if #available(iOS 11.0, macOS 10.13, watchOS 4.0, tvOS 11.0, *) {
|
||||
|
||||
return try! NSKeyedArchiver.archivedData(
|
||||
withRootObject: fieldValue,
|
||||
requiringSecureCoding: self.requiresSecureCoding
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
||||
return NSKeyedArchiver.archivedData(withRootObject: fieldValue)
|
||||
}
|
||||
return try! NSKeyedArchiver.archivedData(
|
||||
withRootObject: fieldValue,
|
||||
requiringSecureCoding: self.requiresSecureCoding
|
||||
)
|
||||
}
|
||||
|
||||
public static func decodeFromStoredData(_ data: Data?) -> FieldStoredValue? {
|
||||
@@ -66,14 +59,10 @@ extension FieldCoders {
|
||||
|
||||
return nil
|
||||
}
|
||||
if #available(iOS 11.0, macOS 10.13, watchOS 4.0, tvOS 11.0, *) {
|
||||
|
||||
return try! NSKeyedUnarchiver.unarchivedObject(ofClass: FieldStoredValue.self, from: data)
|
||||
}
|
||||
else {
|
||||
|
||||
return NSKeyedUnarchiver.unarchiveObject(with: data) as! FieldStoredValue?
|
||||
}
|
||||
return try! NSKeyedUnarchiver.unarchivedObject(
|
||||
ofClass: FieldStoredValue.self,
|
||||
from: data
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -221,7 +221,6 @@ extension From {
|
||||
- parameter clause: the `SectionBy` to be used by the `ListMonitor`
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy(_ clause: SectionBy<O>) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return .init(
|
||||
@@ -237,7 +236,6 @@ extension From {
|
||||
- parameter sectionKeyPath: the key path to use to group the objects into sections
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy(_ sectionKeyPath: KeyPathString) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return self.sectionBy(sectionKeyPath, sectionIndexTransformer: { _ in nil })
|
||||
@@ -251,7 +249,6 @@ extension From {
|
||||
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section index title
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy(
|
||||
_ sectionKeyPath: KeyPathString,
|
||||
sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -284,7 +281,6 @@ extension From {
|
||||
// MARK: Deprecated
|
||||
|
||||
@available(*, deprecated, renamed: "sectionBy(_:sectionIndexTransformer:)")
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy(
|
||||
_ sectionKeyPath: KeyPathString,
|
||||
_ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -319,7 +315,6 @@ extension From where O: NSManagedObject {
|
||||
- parameter sectionKeyPath: the `KeyPath` to use to group the objects into sections
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, T>) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return self.sectionBy(
|
||||
@@ -336,7 +331,6 @@ extension From where O: NSManagedObject {
|
||||
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section index title
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, T>,
|
||||
sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -352,7 +346,6 @@ extension From where O: NSManagedObject {
|
||||
// MARK: Deprecated
|
||||
|
||||
@available(*, deprecated, renamed: "sectionBy(_:sectionIndexTransformer:)")
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, T>,
|
||||
_ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -431,7 +424,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionKeyPath: the `KeyPath` to use to group the objects into sections
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, FieldContainer<O>.Stored<T>>) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return self.sectionBy(
|
||||
@@ -446,7 +438,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionKeyPath: the `KeyPath` to use to group the objects into sections
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, FieldContainer<O>.Virtual<T>>) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return self.sectionBy(
|
||||
@@ -461,7 +452,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionKeyPath: the `KeyPath` to use to group the objects into sections
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, FieldContainer<O>.Coded<T>>) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return self.sectionBy(
|
||||
@@ -476,7 +466,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionKeyPath: the `KeyPath` to use to group the objects into sections
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Required<T>>) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return self.sectionBy(
|
||||
@@ -491,7 +480,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionKeyPath: the `KeyPath` to use to group the objects into sections
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Optional<T>>) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return self.sectionBy(
|
||||
@@ -506,7 +494,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionKeyPath: the `KeyPath` to use to group the objects into sections
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Required<T>>) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return self.sectionBy(
|
||||
@@ -521,7 +508,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionKeyPath: the `KeyPath` to use to group the objects into sections
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>) -> SectionMonitorChainBuilder<O> {
|
||||
|
||||
return self.sectionBy(
|
||||
@@ -538,7 +524,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section index title
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, FieldContainer<O>.Stored<T>>,
|
||||
sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -558,7 +543,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section index title
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, FieldContainer<O>.Virtual<T>>,
|
||||
sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -578,7 +562,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section index title
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, FieldContainer<O>.Coded<T>>,
|
||||
sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -598,7 +581,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section index title
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Required<T>>,
|
||||
sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -618,7 +600,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section index title
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Optional<T>>,
|
||||
sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -638,7 +619,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section index title
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Required<T>>,
|
||||
sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -658,7 +638,6 @@ extension From where O: CoreStoreObject {
|
||||
- parameter sectionIndexTransformer: a closure to transform the value for the key path to an appropriate section index title
|
||||
- returns: a `SectionMonitorChainBuilder` that is sectioned by the specified key path
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>,
|
||||
sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -674,7 +653,6 @@ extension From where O: CoreStoreObject {
|
||||
// MARK: Deprecated
|
||||
|
||||
@available(*, deprecated, renamed: "sectionBy(_:sectionIndexTransformer:)")
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, FieldContainer<O>.Stored<T>>,
|
||||
_ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -687,7 +665,6 @@ extension From where O: CoreStoreObject {
|
||||
}
|
||||
|
||||
@available(*, deprecated, renamed: "sectionBy(_:sectionIndexTransformer:)")
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, FieldContainer<O>.Virtual<T>>,
|
||||
_ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -700,7 +677,6 @@ extension From where O: CoreStoreObject {
|
||||
}
|
||||
|
||||
@available(*, deprecated, renamed: "sectionBy(_:sectionIndexTransformer:)")
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, FieldContainer<O>.Coded<T>>,
|
||||
_ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -713,7 +689,6 @@ extension From where O: CoreStoreObject {
|
||||
}
|
||||
|
||||
@available(*, deprecated, renamed: "sectionBy(_:sectionIndexTransformer:)")
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Required<T>>,
|
||||
_ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -726,7 +701,6 @@ extension From where O: CoreStoreObject {
|
||||
}
|
||||
|
||||
@available(*, deprecated, renamed: "sectionBy(_:sectionIndexTransformer:)")
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, ValueContainer<O>.Optional<T>>,
|
||||
_ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -739,7 +713,6 @@ extension From where O: CoreStoreObject {
|
||||
}
|
||||
|
||||
@available(*, deprecated, renamed: "sectionBy(_:sectionIndexTransformer:)")
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Required<T>>,
|
||||
_ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -752,7 +725,6 @@ extension From where O: CoreStoreObject {
|
||||
}
|
||||
|
||||
@available(*, deprecated, renamed: "sectionBy(_:sectionIndexTransformer:)")
|
||||
@available(macOS 10.12, *)
|
||||
public func sectionBy<T>(
|
||||
_ sectionKeyPath: KeyPath<O, TransformableContainer<O>.Optional<T>>,
|
||||
_ sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?
|
||||
@@ -1224,7 +1196,6 @@ extension QueryChainBuilder where O: CoreStoreObject {
|
||||
|
||||
// MARK: - SectionMonitorChainBuilder
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension SectionMonitorChainBuilder {
|
||||
|
||||
/**
|
||||
@@ -1376,7 +1347,6 @@ extension SectionMonitorChainBuilder {
|
||||
|
||||
// MARK: - SectionMonitorChainBuilder where O: CoreStoreObject
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension SectionMonitorChainBuilder where O: CoreStoreObject {
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,22 +68,8 @@ extension Internals {
|
||||
}
|
||||
set {
|
||||
|
||||
if #available(iOS 11.0, macOS 10.13, watchOS 4.0, tvOS 11.0, *) {
|
||||
|
||||
self.copiedAffectedStores = (newValue as NSArray?)?.copy() as! NSArray?
|
||||
super.affectedStores = newValue
|
||||
return
|
||||
}
|
||||
// Bugfix for NSFetchRequest messing up memory management for `affectedStores`
|
||||
// http://stackoverflow.com/questions/14396375/nsfetchedresultscontroller-crashes-in-ios-6-if-affectedstores-is-specified
|
||||
if let releaseArray = self.releaseArray {
|
||||
|
||||
releaseArray.release()
|
||||
self.releaseArray = nil
|
||||
}
|
||||
self.copiedAffectedStores = (newValue as NSArray?)?.copy() as! NSArray?
|
||||
super.affectedStores = newValue
|
||||
self.releaseArray = (super.affectedStores as NSArray?).map(Unmanaged<NSArray>.passRetained(_:))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ extension Internals {
|
||||
|
||||
// MARK: - CoreStoreFetchedResultsController
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
internal final class CoreStoreFetchedResultsController: NSFetchedResultsController<NSManagedObject> {
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
@@ -29,7 +29,6 @@ import CoreData
|
||||
|
||||
// MARK: - FetchedResultsControllerHandler
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
internal protocol FetchedResultsControllerHandler: AnyObject {
|
||||
|
||||
var sectionIndexTransformer: (_ sectionName: KeyPathString?) -> String? { get }
|
||||
@@ -50,7 +49,6 @@ extension Internals {
|
||||
|
||||
// MARK: - FetchedResultsControllerDelegate
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
internal final class FetchedResultsControllerDelegate: NSObject, NSFetchedResultsControllerDelegate {
|
||||
|
||||
// MARK: Internal
|
||||
@@ -90,14 +88,6 @@ extension Internals {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if #available(iOS 10.3, tvOS 10.3, watchOS 3.2, macOS 10.13, *) {}
|
||||
else {
|
||||
|
||||
self.deletedSections = []
|
||||
self.insertedSections = []
|
||||
}
|
||||
|
||||
self.handler?.controllerWillChangeContent(controller)
|
||||
}
|
||||
|
||||
@@ -123,102 +113,11 @@ extension Internals {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if #available(iOS 10.3, tvOS 10.3, watchOS 3.2, macOS 10.13, *) {
|
||||
|
||||
self.handler?.controller(
|
||||
controller,
|
||||
didChangeObject: anObject,
|
||||
atIndexPath: indexPath,
|
||||
forChangeType: type,
|
||||
newIndexPath: newIndexPath
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
guard var actualType = NSFetchedResultsChangeType(rawValue: type.rawValue) else {
|
||||
|
||||
// This fix is for a bug where iOS passes 0 for NSFetchedResultsChangeType, but this is not a valid enum case.
|
||||
// Swift will then always execute the first case of the switch causing strange behaviour.
|
||||
// https://forums.developer.apple.com/thread/12184#31850
|
||||
return
|
||||
}
|
||||
|
||||
// This whole dance is a workaround for a nasty bug introduced in XCode 7 targeted at iOS 8 devices
|
||||
// http://stackoverflow.com/questions/31383760/ios-9-attempt-to-delete-and-reload-the-same-index-path/31384014#31384014
|
||||
// https://forums.developer.apple.com/message/9998#9998
|
||||
// https://forums.developer.apple.com/message/31849#31849
|
||||
|
||||
if case .update = actualType,
|
||||
indexPath != nil,
|
||||
newIndexPath != nil {
|
||||
|
||||
actualType = .move
|
||||
}
|
||||
|
||||
switch actualType {
|
||||
|
||||
case .update:
|
||||
guard let section = indexPath?[0] else {
|
||||
|
||||
return
|
||||
}
|
||||
if self.deletedSections.contains(section)
|
||||
|| self.insertedSections.contains(section) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case .move:
|
||||
guard let indexPath = indexPath, let newIndexPath = newIndexPath else {
|
||||
|
||||
return
|
||||
}
|
||||
guard indexPath == newIndexPath else {
|
||||
|
||||
break
|
||||
}
|
||||
if self.insertedSections.contains(indexPath[0]) {
|
||||
|
||||
// Observers that handle the .Move change are advised to delete then reinsert the object instead of just moving. This is especially true when indexPath and newIndexPath are equal. For example, calling tableView.moveRowAtIndexPath(_:toIndexPath) when both indexPaths are the same will crash the tableView.
|
||||
self.handler?.controller(
|
||||
controller,
|
||||
didChangeObject: anObject,
|
||||
atIndexPath: indexPath,
|
||||
forChangeType: .move,
|
||||
newIndexPath: newIndexPath
|
||||
)
|
||||
return
|
||||
}
|
||||
if self.deletedSections.contains(indexPath[0]) {
|
||||
|
||||
self.handler?.controller(
|
||||
controller,
|
||||
didChangeObject: anObject,
|
||||
atIndexPath: nil,
|
||||
forChangeType: .insert,
|
||||
newIndexPath: indexPath
|
||||
)
|
||||
return
|
||||
}
|
||||
self.handler?.controller(
|
||||
controller,
|
||||
didChangeObject: anObject,
|
||||
atIndexPath: indexPath,
|
||||
forChangeType: .update,
|
||||
newIndexPath: nil
|
||||
)
|
||||
return
|
||||
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
self.handler?.controller(
|
||||
controller,
|
||||
didChangeObject: anObject,
|
||||
atIndexPath: indexPath,
|
||||
forChangeType: actualType,
|
||||
forChangeType: type,
|
||||
newIndexPath: newIndexPath
|
||||
)
|
||||
}
|
||||
@@ -230,18 +129,6 @@ extension Internals {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if #available(iOS 10.3, tvOS 10.3, watchOS 3.2, macOS 10.13, *) {}
|
||||
else {
|
||||
|
||||
switch type {
|
||||
|
||||
case .delete: self.deletedSections.insert(sectionIndex)
|
||||
case .insert: self.insertedSections.insert(sectionIndex)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
|
||||
self.handler?.controller(
|
||||
controller,
|
||||
didChangeSection: sectionInfo,
|
||||
@@ -255,14 +142,5 @@ extension Internals {
|
||||
|
||||
return self.handler?.sectionIndexTransformer(sectionName)
|
||||
}
|
||||
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@nonobjc
|
||||
private var deletedSections = Set<Int>()
|
||||
|
||||
@nonobjc
|
||||
private var insertedSections = Set<Int>()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,6 @@ import CoreData
|
||||
```
|
||||
In the example above, both `person1` and `person2` will contain the object at section=2, index=3.
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public final class ListMonitor<O: DynamicObject>: Hashable {
|
||||
|
||||
// MARK: Public (Accessors)
|
||||
@@ -1178,7 +1177,6 @@ public final class ListMonitor<O: DynamicObject>: Hashable {
|
||||
|
||||
// MARK: - ListMonitor where O: NSManagedObject
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ListMonitor where O: NSManagedObject {
|
||||
|
||||
/**
|
||||
@@ -1236,7 +1234,6 @@ extension ListMonitor where O: NSManagedObject {
|
||||
|
||||
// MARK: - ListMonitor where O: CoreStoreObject
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ListMonitor where O: CoreStoreObject {
|
||||
|
||||
/**
|
||||
@@ -1288,7 +1285,6 @@ extension ListMonitor where O: CoreStoreObject {
|
||||
|
||||
// MARK: - ListMonitor: FetchedResultsControllerHandler
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ListMonitor: FetchedResultsControllerHandler {
|
||||
|
||||
// MARK: FetchedResultsControllerHandler
|
||||
@@ -1402,7 +1398,6 @@ extension ListMonitor: FetchedResultsControllerHandler {
|
||||
|
||||
// MARK: - Notification Keys
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension Notification.Name {
|
||||
|
||||
fileprivate static let listMonitorWillChangeList = Notification.Name(rawValue: "listMonitorWillChangeList")
|
||||
|
||||
@@ -39,7 +39,6 @@ import CoreData
|
||||
monitor.addObserver(self)
|
||||
```
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public protocol ListObserver: AnyObject {
|
||||
|
||||
/**
|
||||
@@ -82,7 +81,6 @@ public protocol ListObserver: AnyObject {
|
||||
|
||||
// MARK: - ListObserver (Default Implementations)
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ListObserver {
|
||||
|
||||
public func listMonitorWillChange(_ monitor: ListMonitor<ListEntityType>) { }
|
||||
@@ -103,7 +101,6 @@ extension ListObserver {
|
||||
monitor.addObserver(self)
|
||||
```
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public protocol ListObjectObserver: ListObserver {
|
||||
|
||||
/**
|
||||
@@ -151,7 +148,6 @@ public protocol ListObjectObserver: ListObserver {
|
||||
|
||||
// MARK: - ListObjectObserver (Default Implementations)
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ListObjectObserver {
|
||||
|
||||
public func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertObject object: ListEntityType, toIndexPath indexPath: IndexPath) { }
|
||||
@@ -177,7 +173,6 @@ extension ListObjectObserver {
|
||||
monitor.addObserver(self)
|
||||
```
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public protocol ListSectionObserver: ListObjectObserver {
|
||||
|
||||
/**
|
||||
@@ -204,7 +199,6 @@ public protocol ListSectionObserver: ListObjectObserver {
|
||||
|
||||
// MARK: - ListSectionObserver (Default Implementations)
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ListSectionObserver {
|
||||
|
||||
public func listMonitor(_ monitor: ListMonitor<ListEntityType>, didInsertSection sectionInfo: NSFetchedResultsSectionInfo, toSectionIndex sectionIndex: Int) { }
|
||||
|
||||
@@ -54,7 +54,6 @@ import CoreData
|
||||
```
|
||||
All access to the `ListPublisher` items should be done via its `snapshot` value, which is a `struct` of type `ListSnapshot<O>`. `ListSnapshot`s are also designed to work well with `DiffableDataSource.TableViewAdapter`s and `DiffableDataSource.CollectionViewAdapter`s. For detailed examples, refer to the documentation for `DiffableDataSource.TableViewAdapter` and `DiffableDataSource.CollectionViewAdapter`.
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public final class ListPublisher<O: DynamicObject>: Hashable {
|
||||
|
||||
// MARK: Public (Accessors)
|
||||
|
||||
@@ -29,7 +29,6 @@ import CoreData
|
||||
|
||||
// MARK: - DataStack
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension DataStack {
|
||||
|
||||
/**
|
||||
@@ -114,7 +113,6 @@ extension DataStack {
|
||||
|
||||
// MARK: - UnsafeDataTransaction
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension UnsafeDataTransaction {
|
||||
|
||||
/**
|
||||
@@ -204,7 +202,6 @@ extension Internals {
|
||||
|
||||
// MARK: FilePrivate
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
fileprivate static func createFRC<O: NSManagedObject>(fromContext context: NSManagedObjectContext, from: From<O>, sectionBy: SectionBy<O>? = nil, fetchClauses: [FetchClause]) -> NSFetchedResultsController<O> {
|
||||
|
||||
let controller = Internals.CoreStoreFetchedResultsController(
|
||||
|
||||
@@ -230,14 +230,7 @@ extension NSManagedObjectContext {
|
||||
@nonobjc
|
||||
internal func refreshAndMergeAllObjects() {
|
||||
|
||||
if #available(iOS 8.3, macOS 10.11, *) {
|
||||
|
||||
self.refreshAllObjects()
|
||||
}
|
||||
else {
|
||||
|
||||
self.registeredObjects.forEach { self.refresh($0, mergeChanges: true) }
|
||||
}
|
||||
self.refreshAllObjects()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ import CoreData
|
||||
|
||||
Observers registered via `addObserver(_:)` are not retained. `ObjectMonitor` only keeps a `weak` reference to all observers, thus keeping itself free from retain-cycles.
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public final class ObjectMonitor<O: DynamicObject>: Hashable, ObjectRepresentation {
|
||||
|
||||
/**
|
||||
@@ -376,7 +375,6 @@ public final class ObjectMonitor<O: DynamicObject>: Hashable, ObjectRepresentati
|
||||
|
||||
// MARK: - ObjectMonitor: FetchedResultsControllerHandler
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ObjectMonitor: FetchedResultsControllerHandler {
|
||||
|
||||
// MARK: FetchedResultsControllerHandler
|
||||
@@ -426,7 +424,6 @@ extension ObjectMonitor: FetchedResultsControllerHandler {
|
||||
|
||||
// MARK: - Notification.Name
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension Notification.Name {
|
||||
|
||||
fileprivate static let objectMonitorWillChangeObject = Notification.Name(rawValue: "objectMonitorWillChangeObject")
|
||||
|
||||
@@ -36,7 +36,6 @@ import CoreData
|
||||
monitor.addObserver(self)
|
||||
```
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public protocol ObjectObserver: AnyObject {
|
||||
|
||||
/**
|
||||
@@ -76,7 +75,6 @@ public protocol ObjectObserver: AnyObject {
|
||||
|
||||
// MARK: - ObjectObserver (Default Implementations)
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension ObjectObserver {
|
||||
|
||||
public func objectMonitor(_ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType) { }
|
||||
|
||||
@@ -150,15 +150,10 @@ public final class SQLiteStore: LocalStorage {
|
||||
[NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
```
|
||||
*/
|
||||
public let storeOptions: [AnyHashable: Any]? = autoreleasepool {
|
||||
|
||||
var storeOptions: [AnyHashable: Any] = [NSSQLitePragmasOption: ["journal_mode": "WAL"]]
|
||||
if #available(iOS 11.0, macOS 10.13, tvOSApplicationExtension 11.0, watchOSApplicationExtension 4.0, *) {
|
||||
|
||||
storeOptions[NSBinaryStoreInsecureDecodingCompatibilityOption] = true
|
||||
}
|
||||
return storeOptions
|
||||
}
|
||||
public let storeOptions: [AnyHashable: Any]? = [
|
||||
NSSQLitePragmasOption: ["journal_mode": "WAL"],
|
||||
NSBinaryStoreInsecureDecodingCompatibilityOption: true
|
||||
]
|
||||
|
||||
/**
|
||||
Do not call directly. Used by the `DataStack` internally.
|
||||
|
||||
@@ -39,7 +39,6 @@ import CoreData
|
||||
)
|
||||
```
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public struct SectionBy<O: DynamicObject> {
|
||||
|
||||
/**
|
||||
@@ -99,7 +98,6 @@ public struct SectionBy<O: DynamicObject> {
|
||||
|
||||
// MARK: - SectionBy where O: NSManagedObject
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension SectionBy where O: NSManagedObject {
|
||||
|
||||
/**
|
||||
@@ -152,7 +150,6 @@ extension SectionBy where O: NSManagedObject {
|
||||
|
||||
// MARK: - SectionBy where O: CoreStoreObject
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension SectionBy where O: CoreStoreObject {
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,6 @@ import CoreData
|
||||
)
|
||||
```
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public struct SectionMonitorChainBuilder<O: DynamicObject>: SectionMonitorBuilderType {
|
||||
|
||||
// MARK: SectionMonitorBuilderType
|
||||
@@ -62,7 +61,6 @@ public struct SectionMonitorChainBuilder<O: DynamicObject>: SectionMonitorBuilde
|
||||
/**
|
||||
Utility protocol for `SectionMonitorChainBuilder`. Used in methods that support chained fetch builders.
|
||||
*/
|
||||
@available(macOS 10.12, *)
|
||||
public protocol SectionMonitorBuilderType {
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,6 @@ import CoreData
|
||||
|
||||
// MARK: - UnsafeDataTransaction
|
||||
|
||||
@available(macOS 10.12, *)
|
||||
extension UnsafeDataTransaction {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user