Merge branch 'prototype/Swift_3_2' into prototype/Swift_4_0

This commit is contained in:
John Rommel Estropia
2017-10-07 01:10:28 +09:00
7 changed files with 39 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CoreStore"
s.version = "4.1.1"
s.version = "4.1.3"
s.license = "MIT"
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
s.homepage = "https://github.com/JohnEstropia/CoreStore"

View File

@@ -770,6 +770,7 @@
B52F743C1E9B8724005F3DAC /* XcodeDataModelSchema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XcodeDataModelSchema.swift; sourceTree = "<group>"; };
B52F74491E9B8740005F3DAC /* CoreStoreSchema.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreSchema.swift; sourceTree = "<group>"; };
B52FD3A91E3B3EF10001D919 /* NSManagedObject+Logging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObject+Logging.swift"; sourceTree = "<group>"; };
B53205791F74E9170023927D /* .cocoapods.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .cocoapods.yml; sourceTree = "<group>"; };
B533C4DA1D7D4BFA001383CB /* DispatchQueue+CoreStore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DispatchQueue+CoreStore.swift"; sourceTree = "<group>"; };
B538BA701D15B3E30003A766 /* CoreStoreBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CoreStoreBridge.m; sourceTree = "<group>"; };
B53B275E1EE3B92E00E9B352 /* CoreStoreManagedObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CoreStoreManagedObject.swift; sourceTree = "<group>"; };
@@ -1044,6 +1045,7 @@
B5E84ED91AFF82360064E85B /* LICENSE */,
B5D9C8F61B160ED200E64F0E /* CoreStore.podspec */,
B5BDC91A1C202269008147CD /* Cartfile */,
B53205791F74E9170023927D /* .cocoapods.yml */,
B5BDC9271C2024F2008147CD /* .travis.yml */,
B5AD60CD1C90141E00F2B2E8 /* Package.swift */,
);

2
Sources/.cocoapods.yml Normal file
View File

@@ -0,0 +1,2 @@
try:
project: 'CoreStore.xcworkspace'

View File

@@ -121,7 +121,12 @@ extension CoreStoreObject {
return unsafeDowncast(coreStoreObject, to: self)
}
let coreStoreObject = self.init(rawObject: object)
@inline(__always)
func forceTypeCast<T: CoreStoreObject>(_ type: DynamicObject.Type, to: T.Type) -> T.Type {
return type as! T.Type
}
let coreStoreObject = forceTypeCast(object.entity.dynamicObjectType!, to: self).init(rawObject: object)
object.coreStoreObject = coreStoreObject
return coreStoreObject
}

View File

@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.1.1</string>
<string>4.1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>

View File

@@ -31,6 +31,17 @@ import Foundation
internal extension NSEntityDescription {
@nonobjc
internal var dynamicObjectType: DynamicObject.Type? {
guard let userInfo = self.userInfo,
let typeName = userInfo[UserInfoKey.CoreStoreManagedObjectTypeName] as! String? else {
return nil
}
return (NSClassFromString(typeName) as! DynamicObject.Type)
}
@nonobjc
internal var coreStoreEntity: DynamicEntity? {

View File

@@ -48,6 +48,16 @@ public enum SortKey {
Indicates that the `RawKeyPath` should be sorted in descending order
*/
case descending(RawKeyPath)
/**
Indicates that the `RawKeyPath` should be sorted in ascending order in a case-insenstive manner
*/
case ascendingInsensitive(RawKeyPath)
/**
Indicates that the `RawKeyPath` should be sorted in descending order in a case-insenstive manner
*/
case descendingInsensitive(RawKeyPath)
}
@@ -124,6 +134,12 @@ public struct OrderBy: FetchClause, QueryClause, DeleteClause, Hashable {
case .descending(let keyPath):
return NSSortDescriptor(key: keyPath, ascending: false)
case .ascendingInsensitive(let keyPath):
return NSSortDescriptor(key: keyPath, ascending: true, selector: #selector(NSString.localizedCaseInsensitiveCompare(_:)))
case .descendingInsensitive(let keyPath):
return NSSortDescriptor(key: keyPath, ascending: false, selector: #selector(NSString.localizedCaseInsensitiveCompare(_:)))
}
}
)