From f5ef19098ca872075426d6ced86f8f3882e1a159 Mon Sep 17 00:00:00 2001 From: Elvis Date: Sun, 4 Oct 2020 09:46:54 +0200 Subject: [PATCH] Update project --- .../NSManagedObject+PropertyMapperHelpers.h | 2 +- .../NSManagedObject+PropertyMapperHelpers.m | 6 +--- Source/PropertyMapper/PropertyMapper.h | 6 ++-- Source/Sync.h | 8 ++--- Source/Sync/Sync+NSPersistentContainer.swift | 9 ------ Tests/PropertyMapper/DictionaryTests.swift | 6 ++-- Tests/PropertyMapper/ExportTests.swift | 4 +-- .../137.xcdatamodeld/137.xcdatamodel/contents | 32 +++++++++---------- Tests/Sync/Helpers/Helper.swift | 1 - 9 files changed, 30 insertions(+), 44 deletions(-) diff --git a/Source/PropertyMapper/NSManagedObject+PropertyMapperHelpers.h b/Source/PropertyMapper/NSManagedObject+PropertyMapperHelpers.h index 8d5db627..a9bcdd69 100755 --- a/Source/PropertyMapper/NSManagedObject+PropertyMapperHelpers.h +++ b/Source/PropertyMapper/NSManagedObject+PropertyMapperHelpers.h @@ -1,6 +1,6 @@ @import CoreData; -#import "PropertyMapper.h" +#import /** Internal helpers, not meant to be included in the public APIs. diff --git a/Source/PropertyMapper/NSManagedObject+PropertyMapperHelpers.m b/Source/PropertyMapper/NSManagedObject+PropertyMapperHelpers.m index 5d549893..f8961042 100755 --- a/Source/PropertyMapper/NSManagedObject+PropertyMapperHelpers.m +++ b/Source/PropertyMapper/NSManagedObject+PropertyMapperHelpers.m @@ -240,11 +240,7 @@ - (id)valueForAttributeDescription:(NSAttributeDescription *)attributeDescriptio } else if (stringValueAndURIAttribute) { value = [[NSURL alloc] initWithString:remoteValue]; } else if (dataAttribute) { - if (@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)) { - value = [NSKeyedArchiver archivedDataWithRootObject:remoteValue requiringSecureCoding:false error:nil]; - } else { - value = [NSKeyedArchiver archivedDataWithRootObject:remoteValue]; - } + value = [NSKeyedArchiver archivedDataWithRootObject:remoteValue requiringSecureCoding:false error:nil]; } else if (numberValueAndDecimalAttribute) { NSNumber *number = (NSNumber *)remoteValue; value = [NSDecimalNumber decimalNumberWithDecimal:[number decimalValue]]; diff --git a/Source/PropertyMapper/PropertyMapper.h b/Source/PropertyMapper/PropertyMapper.h index 7b58a22f..ff679c2b 100755 --- a/Source/PropertyMapper/PropertyMapper.h +++ b/Source/PropertyMapper/PropertyMapper.h @@ -1,9 +1,9 @@ @import CoreData; @import Foundation; -#import "NSDate+PropertyMapper.h" -#import "NSEntityDescription+PrimaryKey.h" -#import "Inflections.h" +#import +#import +#import FOUNDATION_EXPORT double PropertyMapperVersionNumber; FOUNDATION_EXPORT const unsigned char PropertyMapperVersionString[]; diff --git a/Source/Sync.h b/Source/Sync.h index d9a73ee9..c81d4187 100644 --- a/Source/Sync.h +++ b/Source/Sync.h @@ -5,7 +5,7 @@ FOUNDATION_EXPORT double SyncVersionNumber; FOUNDATION_EXPORT const unsigned char SyncVersionString[]; -#import "PropertyMapper.h" -#import "NSEntityDescription+PrimaryKey.h" -#import "NSManagedObject+PropertyMapperHelpers.h" -#import "NSPropertyDescription+Sync.h" +#import +#import +#import +#import diff --git a/Source/Sync/Sync+NSPersistentContainer.swift b/Source/Sync/Sync+NSPersistentContainer.swift index 0534d390..2525bd89 100644 --- a/Source/Sync/Sync+NSPersistentContainer.swift +++ b/Source/Sync/Sync+NSPersistentContainer.swift @@ -1,6 +1,5 @@ import CoreData -@available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) public extension NSPersistentContainer { /** Syncs the entity using the received array of dictionaries, maps one-to-many, many-to-many and one-to-one relationships. @@ -11,7 +10,6 @@ public extension NSPersistentContainer { - parameter entityName: The name of the entity to be synced. - parameter completion: The completion block, it returns an error if something in the Sync process goes wrong. */ - @available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) func sync(_ changes: [[String: Any]], inEntityNamed entityName: String, completion: ((_ error: NSError?) -> Void)?) { self.sync(changes, inEntityNamed: entityName, predicate: nil, parent: nil, parentRelationship: nil, operations: .all, completion: completion) } @@ -27,7 +25,6 @@ public extension NSPersistentContainer { account in the Sync process, you just need to provide this predicate. - parameter completion: The completion block, it returns an error if something in the Sync process goes wrong. */ - @available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) func sync(_ changes: [[String: Any]], inEntityNamed entityName: String, predicate: NSPredicate?, completion: ((_ error: NSError?) -> Void)?) { Sync.changes(changes, inEntityNamed: entityName, predicate: predicate, persistentContainer: self, operations: .all, completion: completion) } @@ -44,7 +41,6 @@ public extension NSPersistentContainer { - parameter operations: The type of operations to be applied to the data, Insert, Update, Delete or any possible combination. - parameter completion: The completion block, it returns an error if something in the Sync process goes wrong. */ - @available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) func sync(_ changes: [[String: Any]], inEntityNamed entityName: String, predicate: NSPredicate?, parent: NSManagedObject?, parentRelationship: NSRelationshipDescription?, operations: Sync.OperationOptions, completion: ((_ error: NSError?) -> Void)?) { self.performBackgroundTask { backgroundContext in Sync.changes(changes, inEntityNamed: entityName, predicate: predicate, parent: parent, parentRelationship: parentRelationship, inContext: backgroundContext, operations: operations, completion: completion) @@ -58,7 +54,6 @@ public extension NSPersistentContainer { /// - entityName: The name of the entity. /// - id: The primary key. /// - completion: The completion block. - @available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) func insertOrUpdate(_ changes: [String: Any], inEntityNamed entityName: String, completion: @escaping (_ result: SyncResult) -> Void) { self.performBackgroundTask { backgroundContext in do { @@ -83,7 +78,6 @@ public extension NSPersistentContainer { /// - changes: The dictionary to be used to update the object. /// - entityName: The name of the entity. /// - completion: The completion block. - @available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) func update(_ id: Any, with changes: [String: Any], inEntityNamed entityName: String, completion: @escaping (_ result: SyncResult) -> Void) { self.performBackgroundTask { backgroundContext in do { @@ -109,7 +103,6 @@ public extension NSPersistentContainer { /// - id: The primary key. /// - entityName: The name of the entity. /// - completion: The completion block. - @available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) func delete(_ id: Any, inEntityNamed entityName: String, completion: @escaping (_ error: NSError?) -> Void) { self.performBackgroundTask { backgroundContext in do { @@ -194,7 +187,6 @@ public extension Sync { - parameter persistentContainer: The NSPersistentContainer instance. - parameter completion: The completion block, it returns an error if something in the Sync process goes wrong. */ - @available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) class func changes(_ changes: [[String: Any]], inEntityNamed entityName: String, predicate: NSPredicate?, persistentContainer: NSPersistentContainer, completion: ((_ error: NSError?) -> Void)?) { self.changes(changes, inEntityNamed: entityName, predicate: predicate, persistentContainer: persistentContainer, operations: .all, completion: completion) } @@ -212,7 +204,6 @@ public extension Sync { - parameter operations: The type of operations to be applied to the data, Insert, Update, Delete or any possible combination. - parameter completion: The completion block, it returns an error if something in the Sync process goes wrong. */ - @available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) class func changes(_ changes: [[String: Any]], inEntityNamed entityName: String, predicate: NSPredicate?, persistentContainer: NSPersistentContainer, operations: Sync.OperationOptions, completion: ((_ error: NSError?) -> Void)?) { persistentContainer.performBackgroundTask { backgroundContext in self.changes(changes, inEntityNamed: entityName, predicate: predicate, parent: nil, parentRelationship: nil, inContext: backgroundContext, operations: operations, completion: completion) diff --git a/Tests/PropertyMapper/DictionaryTests.swift b/Tests/PropertyMapper/DictionaryTests.swift index c543c6a1..97efb2c7 100755 --- a/Tests/PropertyMapper/DictionaryTests.swift +++ b/Tests/PropertyMapper/DictionaryTests.swift @@ -23,10 +23,10 @@ class DictionaryTests: XCTestCase { let user = NSEntityDescription.insertNewObject(forEntityName: "InflectionUser", into: dataStack.mainContext) user.hyp_fill(with: self.sampleSnakeCaseJSON) try! dataStack.mainContext.save() - + let compared = [ "description": "reserved", - "inflection_binary_data": NSKeyedArchiver.archivedData(withRootObject: ["one", "two"]) as NSData, + "inflection_binary_data": try! NSKeyedArchiver.archivedData(withRootObject: ["one", "two"], requiringSecureCoding: false) as NSData, "inflection_date": "1970-01-01", "randomRemoteKey": "randomRemoteKey", "inflection_id": 1, @@ -60,7 +60,7 @@ class DictionaryTests: XCTestCase { let compared = [ "description": "reserved", - "inflectionBinaryData": NSKeyedArchiver.archivedData(withRootObject: ["one", "two"]) as NSData, + "inflectionBinaryData": try! NSKeyedArchiver.archivedData(withRootObject: ["one", "two"], requiringSecureCoding: false) as NSData, "inflectionDate": "1970-01-01", "randomRemoteKey": "randomRemoteKey", "inflectionID": 1, diff --git a/Tests/PropertyMapper/ExportTests.swift b/Tests/PropertyMapper/ExportTests.swift index fa03163a..46d84b0f 100644 --- a/Tests/PropertyMapper/ExportTests.swift +++ b/Tests/PropertyMapper/ExportTests.swift @@ -26,7 +26,7 @@ class ExportTests: XCTestCase { let compared = [ "description": "reserved", - "inflection_binary_data": NSKeyedArchiver.archivedData(withRootObject: ["one", "two"]) as NSData, + "inflection_binary_data": try! NSKeyedArchiver.archivedData(withRootObject: ["one", "two"], requiringSecureCoding: false) as NSData, "inflection_date": "1970-01-01", "randomRemoteKey": "randomRemoteKey", "inflection_id": 1, @@ -62,7 +62,7 @@ class ExportTests: XCTestCase { let compared = [ "description": "reserved", - "inflectionBinaryData": NSKeyedArchiver.archivedData(withRootObject: ["one", "two"]) as NSData, + "inflectionBinaryData": try! NSKeyedArchiver.archivedData(withRootObject: ["one", "two"], requiringSecureCoding: false) as NSData, "inflectionDate": "1970-01-01", "randomRemoteKey": "randomRemoteKey", "inflectionID": 1, diff --git a/Tests/PropertyMapper/Models/137.xcdatamodeld/137.xcdatamodel/contents b/Tests/PropertyMapper/Models/137.xcdatamodeld/137.xcdatamodel/contents index bc33a2b5..5c23ad10 100644 --- a/Tests/PropertyMapper/Models/137.xcdatamodeld/137.xcdatamodel/contents +++ b/Tests/PropertyMapper/Models/137.xcdatamodeld/137.xcdatamodel/contents @@ -1,37 +1,37 @@ - + - - + + - + - + - - - - - - - - - - + + + + + + + + + + - + \ No newline at end of file diff --git a/Tests/Sync/Helpers/Helper.swift b/Tests/Sync/Helpers/Helper.swift index 77525ed0..0a525896 100644 --- a/Tests/Sync/Helpers/Helper.swift +++ b/Tests/Sync/Helpers/Helper.swift @@ -17,7 +17,6 @@ import Sync return dataStack } - @available(iOS 10, watchOS 3, tvOS 10, OSX 10.12, *) class func persistentStoreWithModelName(_ modelName: String) -> NSPersistentContainer { let momdModelURL = Bundle(for: NSPersistentContainerTests.self).url(forResource: modelName, withExtension: "momd")! let model = NSManagedObjectModel(contentsOf: momdModelURL)!