From d7edd2d1b1a40daa7d2dd08e03c334d78491d3a0 Mon Sep 17 00:00:00 2001 From: "Telintelo, Brian" Date: Wed, 3 Jan 2018 13:13:22 -0500 Subject: [PATCH 1/2] upgraded to swift 4 --- .../AlecrimCoreData.xcodeproj/project.pbxproj | 22 +++++-- .../xcschemes/AlecrimCoreData.xcscheme | 4 +- .../NSManagedObjectExtensions.swift | 2 +- .../Core/Protocols/AttributeProtocol.swift | 62 +++++++++---------- .../Protocols/AttributeQueryProtocol.swift | 2 +- .../Core/Protocols/CoreDataQueryable.swift | 18 +++--- .../Core/Protocols/Enumerable.swift | 8 +-- .../Core/Protocols/GenericQueryable.swift | 26 ++++---- .../Core/Protocols/Queryable.swift | 10 +-- .../Core/Protocols/TableProtocol.swift | 14 ++--- 10 files changed, 91 insertions(+), 77 deletions(-) diff --git a/Source/AlecrimCoreData.xcodeproj/project.pbxproj b/Source/AlecrimCoreData.xcodeproj/project.pbxproj index b7fb4c4..ea5e57f 100644 --- a/Source/AlecrimCoreData.xcodeproj/project.pbxproj +++ b/Source/AlecrimCoreData.xcodeproj/project.pbxproj @@ -238,12 +238,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0810; + LastUpgradeCheck = 0920; ORGANIZATIONNAME = Alecrim; TargetAttributes = { 1447ADCB1B52B2F000ADEAED = { CreatedOnToolsVersion = 7.0; - LastSwiftMigration = 0800; + LastSwiftMigration = 0920; }; }; }; @@ -318,14 +318,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; 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_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 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_OBJC_ROOT_CLASS = YES_ERROR; + 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; @@ -373,14 +379,20 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; 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_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 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_OBJC_ROOT_CLASS = YES_ERROR; + 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; @@ -431,7 +443,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -454,7 +467,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/Source/AlecrimCoreData.xcodeproj/xcshareddata/xcschemes/AlecrimCoreData.xcscheme b/Source/AlecrimCoreData.xcodeproj/xcshareddata/xcschemes/AlecrimCoreData.xcscheme index 33ca2ec..5cc2a2f 100644 --- a/Source/AlecrimCoreData.xcodeproj/xcshareddata/xcschemes/AlecrimCoreData.xcscheme +++ b/Source/AlecrimCoreData.xcodeproj/xcshareddata/xcschemes/AlecrimCoreData.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Source/AlecrimCoreData/Core/Extensions/NSManagedObjectExtensions.swift b/Source/AlecrimCoreData/Core/Extensions/NSManagedObjectExtensions.swift index b3eaa5c..6642d3e 100644 --- a/Source/AlecrimCoreData/Core/Extensions/NSManagedObjectExtensions.swift +++ b/Source/AlecrimCoreData/Core/Extensions/NSManagedObjectExtensions.swift @@ -22,7 +22,7 @@ extension NSManagedObject { let otherManagedObject = try otherContext.existingObject(with: self.objectID) - return unsafeBitCast(otherManagedObject, to: type(of: self)) + return unsafeDowncast(otherManagedObject, to: type(of: self)) } } diff --git a/Source/AlecrimCoreData/Core/Protocols/AttributeProtocol.swift b/Source/AlecrimCoreData/Core/Protocols/AttributeProtocol.swift index caeadef..505df2a 100644 --- a/Source/AlecrimCoreData/Core/Protocols/AttributeProtocol.swift +++ b/Source/AlecrimCoreData/Core/Protocols/AttributeProtocol.swift @@ -63,7 +63,7 @@ public protocol NullableAttributeProtocol: AttributeProtocol { extension AttributeProtocol { - public final var ___expression: NSExpression { + public var ___expression: NSExpression { return NSExpression(forKeyPath: self.___name) } @@ -73,7 +73,7 @@ extension AttributeProtocol { extension AttributeProtocol { - internal final var ___comparisonPredicateOptions: NSComparisonPredicate.Options { + internal var ___comparisonPredicateOptions: NSComparisonPredicate.Options { if Self.ValueType.self is AlecrimCoreData.StringProtocol.Type { return PersistentContainerOptions.defaultComparisonPredicateOptions } @@ -88,7 +88,7 @@ extension AttributeProtocol { extension AttributeProtocol where Self.ValueType: Equatable { - public final func isEqualTo(_ value: Self.ValueType) -> NSComparisonPredicate { + public func isEqualTo(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -98,7 +98,7 @@ extension AttributeProtocol where Self.ValueType: Equatable { ) } - public final func isEqualTo(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { + public func isEqualTo(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: otherAttribute.___expression, @@ -108,7 +108,7 @@ extension AttributeProtocol where Self.ValueType: Equatable { ) } - public final func isNotEqualTo(_ value: Self.ValueType) -> NSComparisonPredicate { + public func isNotEqualTo(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -118,7 +118,7 @@ extension AttributeProtocol where Self.ValueType: Equatable { ) } - public final func isNotEqualTo(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { + public func isNotEqualTo(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: otherAttribute.___expression, @@ -132,7 +132,7 @@ extension AttributeProtocol where Self.ValueType: Equatable { extension NullableAttributeProtocol where Self.ValueType: Equatable { - public final func isEqualTo(_ value: ValueType?) -> NSComparisonPredicate { + public func isEqualTo(_ value: ValueType?) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -142,7 +142,7 @@ extension NullableAttributeProtocol where Self.ValueType: Equatable { ) } - public final func isNotEqualTo(_ value: ValueType?) -> NSComparisonPredicate { + public func isNotEqualTo(_ value: ValueType?) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -156,7 +156,7 @@ extension NullableAttributeProtocol where Self.ValueType: Equatable { extension AttributeProtocol where Self.ValueType: Comparable { - public final func isGreaterThan(_ value: Self.ValueType) -> NSComparisonPredicate { + public func isGreaterThan(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -166,7 +166,7 @@ extension AttributeProtocol where Self.ValueType: Comparable { ) } - public final func isGreaterThan(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { + public func isGreaterThan(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: otherAttribute.___expression, @@ -176,7 +176,7 @@ extension AttributeProtocol where Self.ValueType: Comparable { ) } - public final func isGreaterThanOrEqualTo(_ value: Self.ValueType) -> NSComparisonPredicate { + public func isGreaterThanOrEqualTo(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -186,7 +186,7 @@ extension AttributeProtocol where Self.ValueType: Comparable { ) } - public final func isGreaterThanOrEqualTo(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { + public func isGreaterThanOrEqualTo(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: otherAttribute.___expression, @@ -196,7 +196,7 @@ extension AttributeProtocol where Self.ValueType: Comparable { ) } - public final func isLessThan(_ value: Self.ValueType) -> NSComparisonPredicate { + public func isLessThan(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -206,7 +206,7 @@ extension AttributeProtocol where Self.ValueType: Comparable { ) } - public final func isLessThan(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { + public func isLessThan(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: otherAttribute.___expression, @@ -216,7 +216,7 @@ extension AttributeProtocol where Self.ValueType: Comparable { ) } - public final func isLessThanOrEqualTo(_ value: Self.ValueType) -> NSComparisonPredicate { + public func isLessThanOrEqualTo(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -226,7 +226,7 @@ extension AttributeProtocol where Self.ValueType: Comparable { ) } - public final func isLessThanOrEqualTo(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { + public func isLessThanOrEqualTo(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: otherAttribute.___expression, @@ -240,7 +240,7 @@ extension AttributeProtocol where Self.ValueType: Comparable { extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol { - public final func isLike(_ value: Self.ValueType) -> NSComparisonPredicate { + public func isLike(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -250,7 +250,7 @@ extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol ) } - public final func isIn(_ value: Self.ValueType) -> NSComparisonPredicate { + public func isIn(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -264,7 +264,7 @@ extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol extension AttributeProtocol { - public final func isIn(_ values: [Self.ValueType]) -> NSComparisonPredicate { + public func isIn(_ values: [Self.ValueType]) -> NSComparisonPredicate { let rightExpressionConstanteValue = values.map { toNSObject($0) } let rightExpression = NSExpression(forConstantValue: rightExpressionConstanteValue) @@ -281,7 +281,7 @@ extension AttributeProtocol { extension AttributeProtocol where Self.ValueType: Comparable { - public final func isBetween(_ range: Range) -> NSComparisonPredicate { + public func isBetween(_ range: Range) -> NSComparisonPredicate { let rightExpressionConstanteValue = [toNSObject(range.lowerBound), toNSObject(range.upperBound)] as NSArray let rightExpression = NSExpression(forConstantValue: rightExpressionConstanteValue) @@ -298,7 +298,7 @@ extension AttributeProtocol where Self.ValueType: Comparable { extension AttributeProtocol where Self.ValueType: ExpressibleByBooleanLiteral { - public final func not() -> NSComparisonPredicate { + public func not() -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: NSExpression(forConstantValue: NSNumber(value: false)), @@ -312,7 +312,7 @@ extension AttributeProtocol where Self.ValueType: ExpressibleByBooleanLiteral { extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol { - public final func contains(_ value: Self.ValueType) -> NSComparisonPredicate { + public func contains(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -322,7 +322,7 @@ extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol ) } - public final func contains(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { + public func contains(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: otherAttribute.___expression, @@ -332,7 +332,7 @@ extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol ) } - public final func beginsWith(_ value: Self.ValueType) -> NSComparisonPredicate { + public func beginsWith(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -342,7 +342,7 @@ extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol ) } - public final func beginsWith(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { + public func beginsWith(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: otherAttribute.___expression, @@ -352,7 +352,7 @@ extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol ) } - public final func endsWith(_ value: Self.ValueType) -> NSComparisonPredicate { + public func endsWith(_ value: Self.ValueType) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: expressionForValue(value), @@ -362,7 +362,7 @@ extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol ) } - public final func endsWith(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { + public func endsWith(_ otherAttribute: T) -> NSComparisonPredicate where T.ValueType == Self.ValueType { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: otherAttribute.___expression, @@ -376,7 +376,7 @@ extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol { - public final func matches(_ regularExpressionString: String) -> NSComparisonPredicate { + public func matches(_ regularExpressionString: String) -> NSComparisonPredicate { return NSComparisonPredicate( leftExpression: self.___expression, rightExpression: NSExpression(forConstantValue: regularExpressionString), @@ -392,7 +392,7 @@ extension AttributeProtocol where Self.ValueType: AlecrimCoreData.StringProtocol extension AttributeProtocol where Self.ValueType: Collection { - public final func any(_ predicateClosure: (Self.ValueType.Iterator.Element.Type) -> NSComparisonPredicate) -> NSComparisonPredicate { + public func any(_ predicateClosure: (Self.ValueType.Iterator.Element.Type) -> NSComparisonPredicate) -> NSComparisonPredicate { let p = predicateClosure(Self.ValueType.Iterator.Element.self) var leftExpression = p.leftExpression @@ -414,7 +414,7 @@ extension AttributeProtocol where Self.ValueType: Collection { ) } - public final func all(_ predicateClosure: (Self.ValueType.Iterator.Element.Type) -> NSComparisonPredicate) -> NSComparisonPredicate { + public func all(_ predicateClosure: (Self.ValueType.Iterator.Element.Type) -> NSComparisonPredicate) -> NSComparisonPredicate { let p = predicateClosure(Self.ValueType.Iterator.Element.self) var leftExpression = p.leftExpression @@ -436,7 +436,7 @@ extension AttributeProtocol where Self.ValueType: Collection { ) } - public final func none(_ predicateClosure: (Self.ValueType.Iterator.Element.Type) -> NSComparisonPredicate) -> NSPredicate { + public func none(_ predicateClosure: (Self.ValueType.Iterator.Element.Type) -> NSComparisonPredicate) -> NSPredicate { let p = predicateClosure(Self.ValueType.Iterator.Element.self) var leftExpression = p.leftExpression diff --git a/Source/AlecrimCoreData/Core/Protocols/AttributeQueryProtocol.swift b/Source/AlecrimCoreData/Core/Protocols/AttributeQueryProtocol.swift index 286bebd..1be804e 100644 --- a/Source/AlecrimCoreData/Core/Protocols/AttributeQueryProtocol.swift +++ b/Source/AlecrimCoreData/Core/Protocols/AttributeQueryProtocol.swift @@ -77,7 +77,7 @@ extension AttributeQueryProtocol where Self.Element: NSDictionary { extension AttributeQueryProtocol where Self.Element: NSDictionary { - public final func toFetchRequest() -> NSFetchRequest { + public func toFetchRequest() -> NSFetchRequest { let fetchRequest = NSFetchRequest() fetchRequest.entity = self.entityDescription diff --git a/Source/AlecrimCoreData/Core/Protocols/CoreDataQueryable.swift b/Source/AlecrimCoreData/Core/Protocols/CoreDataQueryable.swift index 3e62f1d..77b49c4 100644 --- a/Source/AlecrimCoreData/Core/Protocols/CoreDataQueryable.swift +++ b/Source/AlecrimCoreData/Core/Protocols/CoreDataQueryable.swift @@ -9,9 +9,7 @@ import Foundation import CoreData -public protocol CoreDataQueryable: GenericQueryable { - - associatedtype Element: NSFetchRequestResult +public protocol CoreDataQueryable: GenericQueryable where Element: NSFetchRequestResult { var batchSize: Int { get set } @@ -26,7 +24,7 @@ public protocol CoreDataQueryable: GenericQueryable { extension CoreDataQueryable { - public final func count() -> Int { + public func count() -> Int { do { let c = try self.context.count(for: self.toFetchRequest() as NSFetchRequest) @@ -48,33 +46,33 @@ extension CoreDataQueryable { extension CoreDataQueryable { - public final func sum(_ closure: (Self.Element.Type) -> Attribute) -> U { + public func sum(_ closure: (Self.Element.Type) -> Attribute) -> U { let attribute = closure(Self.Element.self) return self.aggregate(withFunctionName: "sum", attribute: attribute) } - public final func min(_ closure: (Self.Element.Type) -> Attribute) -> U { + public func min(_ closure: (Self.Element.Type) -> Attribute) -> U { let attribute = closure(Self.Element.self) return self.aggregate(withFunctionName: "min", attribute: attribute) } - public final func max(_ closure: (Self.Element.Type) -> Attribute) -> U { + public func max(_ closure: (Self.Element.Type) -> Attribute) -> U { let attribute = closure(Self.Element.self) return self.aggregate(withFunctionName: "max", attribute: attribute) } // same as average, for convenience - public final func avg(_ closure: (Self.Element.Type) -> Attribute) -> U { + public func avg(_ closure: (Self.Element.Type) -> Attribute) -> U { let attribute = closure(Self.Element.self) return self.aggregate(withFunctionName: "average", attribute: attribute) } - public final func average(_ closure: (Self.Element.Type) -> Attribute) -> U { + public func average(_ closure: (Self.Element.Type) -> Attribute) -> U { let attribute = closure(Self.Element.self) return self.aggregate(withFunctionName: "average", attribute: attribute) } - private final func aggregate(withFunctionName functionName: String, attribute: Attribute) -> U { + private func aggregate(withFunctionName functionName: String, attribute: Attribute) -> U { let attributeDescription = self.entityDescription.attributesByName[attribute.___name]! let keyPathExpression = NSExpression(forKeyPath: attribute.___name) diff --git a/Source/AlecrimCoreData/Core/Protocols/Enumerable.swift b/Source/AlecrimCoreData/Core/Protocols/Enumerable.swift index b6081a1..039cf6b 100644 --- a/Source/AlecrimCoreData/Core/Protocols/Enumerable.swift +++ b/Source/AlecrimCoreData/Core/Protocols/Enumerable.swift @@ -21,14 +21,14 @@ public protocol Enumerable: Sequence { extension Enumerable { - public final func skip(_ count: Int) -> Self { + public func skip(_ count: Int) -> Self { var clone = self clone.offset = count return clone } - public final func take(_ count: Int) -> Self { + public func take(_ count: Int) -> Self { var clone = self clone.limit = count @@ -39,11 +39,11 @@ extension Enumerable { extension Enumerable { - public final func any() -> Bool { + public func any() -> Bool { return self.take(1).count() == 1 } - public final func none() -> Bool { + public func none() -> Bool { return !self.any() } diff --git a/Source/AlecrimCoreData/Core/Protocols/GenericQueryable.swift b/Source/AlecrimCoreData/Core/Protocols/GenericQueryable.swift index d9a3d3a..d744a1a 100644 --- a/Source/AlecrimCoreData/Core/Protocols/GenericQueryable.swift +++ b/Source/AlecrimCoreData/Core/Protocols/GenericQueryable.swift @@ -20,29 +20,29 @@ public protocol GenericQueryable: Queryable { extension GenericQueryable { - public final func orderBy(ascending: Bool = true, _ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { + public func orderBy(ascending: Bool = true, _ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { return self.sort(using: orderingClosure(Self.Element.self), ascending: ascending) } // convenience methods - public final func orderByAscending(_ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { + public func orderByAscending(_ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { return self.orderBy(ascending: true, orderingClosure) } - public final func orderByDescending(_ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { + public func orderByDescending(_ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { return self.orderBy(ascending: false, orderingClosure) } - public final func thenBy(ascending: Bool = true, _ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { + public func thenBy(ascending: Bool = true, _ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { return self.orderBy(ascending: ascending, orderingClosure) } - public final func thenByAscending(_ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { + public func thenByAscending(_ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { return self.orderBy(ascending: true, orderingClosure) } - public final func thenByDescending(_ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { + public func thenByDescending(_ orderingClosure: (Self.Element.Type) -> A) -> Self where A.ValueType == V { return self.orderBy(ascending: false, orderingClosure) } @@ -52,7 +52,7 @@ extension GenericQueryable { extension GenericQueryable { - public final func filter(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Self { + public func filter(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Self { return self.filter(using: predicateClosure(Self.Element.self)) } @@ -62,7 +62,7 @@ extension GenericQueryable { extension GenericQueryable { - public final func count(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Int { + public func count(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Int { return self.filter(using: predicateClosure(Self.Element.self)).count() } @@ -70,11 +70,11 @@ extension GenericQueryable { extension GenericQueryable { - public final func any(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Bool { + public func any(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Bool { return self.filter(using: predicateClosure(Self.Element.self)).any() } - public final func none(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Bool { + public func none(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Bool { return self.filter(using: predicateClosure(Self.Element.self)).none() } @@ -82,7 +82,7 @@ extension GenericQueryable { extension GenericQueryable { - public final func first(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Self.Element? { + public func first(_ predicateClosure: (Self.Element.Type) -> NSPredicate) -> Self.Element? { return self.filter(using: predicateClosure(Self.Element.self)).first() } @@ -92,7 +92,7 @@ extension GenericQueryable { extension GenericQueryable { - public final func first() -> Self.Element? { + public func first() -> Self.Element? { return self.take(1).execute().first } @@ -102,7 +102,7 @@ extension GenericQueryable { extension GenericQueryable { - public final func makeIterator() -> AnyIterator { + public func makeIterator() -> AnyIterator { return AnyIterator(self.execute().makeIterator()) } diff --git a/Source/AlecrimCoreData/Core/Protocols/Queryable.swift b/Source/AlecrimCoreData/Core/Protocols/Queryable.swift index 8ad7c3a..b11097b 100644 --- a/Source/AlecrimCoreData/Core/Protocols/Queryable.swift +++ b/Source/AlecrimCoreData/Core/Protocols/Queryable.swift @@ -20,11 +20,11 @@ public protocol Queryable: Enumerable { extension Queryable { - public final func sort(using attribute: A, ascending: Bool = true) -> Self { + public func sort(using attribute: A, ascending: Bool = true) -> Self { return self.sort(usingAttributeName: attribute.___name, ascending: ascending, options: attribute.___comparisonPredicateOptions) } - public final func sort(usingAttributeName attributeName: String, ascending: Bool = true, options: NSComparisonPredicate.Options = PersistentContainerOptions.defaultComparisonPredicateOptions) -> Self { + public func sort(usingAttributeName attributeName: String, ascending: Bool = true, options: NSComparisonPredicate.Options = PersistentContainerOptions.defaultComparisonPredicateOptions) -> Self { let sortDescriptor: NSSortDescriptor if options.contains(.caseInsensitive) && options.contains(.diacriticInsensitive) { @@ -43,7 +43,7 @@ extension Queryable { return self.sort(using: sortDescriptor) } - public final func sort(using sortDescriptor: NSSortDescriptor) -> Self { + public func sort(using sortDescriptor: NSSortDescriptor) -> Self { var clone = self if clone.sortDescriptors != nil { @@ -56,7 +56,7 @@ extension Queryable { return clone } - public final func sort(using sortDescriptors: [NSSortDescriptor]) -> Self { + public func sort(using sortDescriptors: [NSSortDescriptor]) -> Self { var clone = self if clone.sortDescriptors != nil { @@ -75,7 +75,7 @@ extension Queryable { extension Queryable { - public final func filter(using predicate: NSPredicate) -> Self { + public func filter(using predicate: NSPredicate) -> Self { var clone = self if let existingPredicate = clone.predicate { diff --git a/Source/AlecrimCoreData/Core/Protocols/TableProtocol.swift b/Source/AlecrimCoreData/Core/Protocols/TableProtocol.swift index b35a6f6..18751c5 100644 --- a/Source/AlecrimCoreData/Core/Protocols/TableProtocol.swift +++ b/Source/AlecrimCoreData/Core/Protocols/TableProtocol.swift @@ -17,15 +17,15 @@ public protocol TableProtocol: CoreDataQueryable { extension TableProtocol where Self.Element: NSManagedObject { - public final func create() -> Self.Element { + public func create() -> Self.Element { return Self.Element(entity: self.entityDescription, insertInto: self.context) } - public final func delete(_ entity: Self.Element) { + public func delete(_ entity: Self.Element) { self.context.delete(entity) } - public final func refresh(_ entity: Self.Element, mergeChanges: Bool = true) { + public func refresh(_ entity: Self.Element, mergeChanges: Bool = true) { self.context.refresh(entity, mergeChanges: mergeChanges) } @@ -33,7 +33,7 @@ extension TableProtocol where Self.Element: NSManagedObject { extension TableProtocol { - public final func deleteAll() { + public func deleteAll() { do { let fetchRequest = self.toFetchRequest() as NSFetchRequest fetchRequest.resultType = .managedObjectIDResultType @@ -54,7 +54,7 @@ extension TableProtocol { extension TableProtocol where Self.Element: NSManagedObject { - public final func firstOrCreated(_ predicateClosure: (Self.Element.Type) -> NSComparisonPredicate) -> Self.Element { + public func firstOrCreated(_ predicateClosure: (Self.Element.Type) -> NSComparisonPredicate) -> Self.Element { let predicate = predicateClosure(Self.Element.self) if let entity = self.filter(using: predicate).first() { @@ -79,7 +79,7 @@ extension TableProtocol where Self.Element: NSManagedObject { extension TableProtocol { - public final func execute() -> [Self.Element] { + public func execute() -> [Self.Element] { do { return try self.context.fetch(self.toFetchRequest() as NSFetchRequest) } @@ -94,7 +94,7 @@ extension TableProtocol { extension TableProtocol { - public final func toFetchRequest() -> NSFetchRequest { + public func toFetchRequest() -> NSFetchRequest { let fetchRequest = NSFetchRequest() fetchRequest.entity = self.entityDescription From 5b14a88d6fc0c140052e99f6423b5597e8412dba Mon Sep 17 00:00:00 2001 From: Vanderlei Martinelli Date: Wed, 7 Mar 2018 04:12:40 -0300 Subject: [PATCH 2/2] Changes before 5.2 version release --- .swift-version | 2 +- AlecrimCoreData.podspec | 6 +++--- README.md | 6 +++--- Source/AlecrimCoreData.xcodeproj/project.pbxproj | 6 ++---- .../AlecrimCoreData/Core/Protocols/AttributeProtocol.swift | 2 +- Source/AlecrimCoreData/Info.plist | 2 +- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.swift-version b/.swift-version index 9f55b2c..5186d07 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +4.0 diff --git a/AlecrimCoreData.podspec b/AlecrimCoreData.podspec index d219a40..599b357 100644 --- a/AlecrimCoreData.podspec +++ b/AlecrimCoreData.podspec @@ -1,14 +1,14 @@ Pod::Spec.new do |s| s.name = "AlecrimCoreData" - s.version = "5.1" + s.version = "5.2" s.summary = "A powerful and simple Core Data wrapper framework written in Swift." - s.homepage = "https://github.com/Alecrim/AlecrimCoreData" + s.homepage = "https://www.alecrim.com/AlecrimCoreData" s.license = "MIT" s.author = { "Vanderlei Martinelli" => "vanderlei.martinelli@gmail.com" } - s.social_media_url = "https://twitter.com/vmartinelli" + s.social_media_url = "https://www.linkedin.com/in/vmartinelli" s.osx.deployment_target = "10.12" s.ios.deployment_target = "9.0" diff --git a/README.md b/README.md index 284dc67..d6e138a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![AlecrimCoreData](https://raw.githubusercontent.com/Alecrim/AlecrimCoreData/master/AlecrimCoreData.png) -[![Language: Swift](https://img.shields.io/badge/Swift-3.2-orange.svg?style=flat)](https://developer.apple.com/swift/) +[![Language: Swift](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat)](https://developer.apple.com/swift/) [![Platform](https://img.shields.io/cocoapods/p/AlecrimCoreData.svg?style=flat)](http://cocoadocs.org/docsets/AlecrimCoreData) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://raw.githubusercontent.com/Alecrim/AlecrimCoreData/develop/LICENSE) [![CocoaPods](https://img.shields.io/cocoapods/v/AlecrimCoreData.svg?style=flat)](http://cocoapods.org) @@ -303,7 +303,7 @@ let filteredPeople = context.people.filter(using: predicate) $ gem install cocoapods ``` -CocoaPods 1.1.0+ is required to build AlecrimCoreData 5.0+. +CocoaPods 1.1.0+ is required to build AlecrimCoreData 5.2+. To integrate **AlecrimCoreData** into your Xcode project using CocoaPods, specify it in your `Podfile`: @@ -314,7 +314,7 @@ use_frameworks! target '' do # pod 'AlecrimCoreData', :git => 'https://github.com/Alecrim/AlecrimCoreData.git', :branch => 'develop' - pod 'AlecrimCoreData', '~> 5.0' + pod 'AlecrimCoreData', '~> 5.2' end ``` diff --git a/Source/AlecrimCoreData.xcodeproj/project.pbxproj b/Source/AlecrimCoreData.xcodeproj/project.pbxproj index a89e2ab..b95c6df 100644 --- a/Source/AlecrimCoreData.xcodeproj/project.pbxproj +++ b/Source/AlecrimCoreData.xcodeproj/project.pbxproj @@ -431,7 +431,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 779; + CURRENT_PROJECT_VERSION = 1743; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -444,7 +444,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 4.0; }; name = Debug; @@ -455,7 +454,7 @@ APPLICATION_EXTENSION_API_ONLY = YES; CLANG_ENABLE_MODULES = YES; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 779; + CURRENT_PROJECT_VERSION = 1743; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -468,7 +467,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 4.0; }; name = Release; diff --git a/Source/AlecrimCoreData/Core/Protocols/AttributeProtocol.swift b/Source/AlecrimCoreData/Core/Protocols/AttributeProtocol.swift index 505df2a..6582aeb 100644 --- a/Source/AlecrimCoreData/Core/Protocols/AttributeProtocol.swift +++ b/Source/AlecrimCoreData/Core/Protocols/AttributeProtocol.swift @@ -537,7 +537,7 @@ public func << (left: A, right: [V]) -> NSComparisonPre return left.isIn(right) } -public func << (left: A, right: Range) -> NSComparisonPredicate where A.ValueType == V { +public func << (left: A, right: Range) -> NSComparisonPredicate where A.ValueType == V { return left.isBetween(right) } diff --git a/Source/AlecrimCoreData/Info.plist b/Source/AlecrimCoreData/Info.plist index 0b144cf..3dae585 100644 --- a/Source/AlecrimCoreData/Info.plist +++ b/Source/AlecrimCoreData/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 5.0 + 5.2 CFBundleSignature ???? CFBundleVersion