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

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(_:)))
}
}
)