mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-16 05:56:50 +01:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a34012d58 | ||
|
|
45690a29c6 | ||
|
|
0d4d036a86 | ||
|
|
ed0fdc76fe | ||
|
|
58f4907575 | ||
|
|
1950224863 | ||
|
|
f0cd288657 |
@@ -1,6 +1,6 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "CoreStore"
|
s.name = "CoreStore"
|
||||||
s.version = "2.0.2"
|
s.version = "2.0.5"
|
||||||
s.license = "MIT"
|
s.license = "MIT"
|
||||||
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
|
s.summary = "Unleashing the real power of Core Data with the elegance and safety of Swift"
|
||||||
s.homepage = "https://github.com/JohnEstropia/CoreStore"
|
s.homepage = "https://github.com/JohnEstropia/CoreStore"
|
||||||
@@ -16,8 +16,9 @@ Pod::Spec.new do |s|
|
|||||||
s.public_header_files = "Sources/**/*.h"
|
s.public_header_files = "Sources/**/*.h"
|
||||||
s.frameworks = "Foundation", "CoreData"
|
s.frameworks = "Foundation", "CoreData"
|
||||||
s.requires_arc = true
|
s.requires_arc = true
|
||||||
s.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-D USE_FRAMEWORKS',
|
s.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS[config=Debug]' => '-D USE_FRAMEWORKS -D DEBUG',
|
||||||
|
'OTHER_SWIFT_FLAGS[config=Release]' => '-D USE_FRAMEWORKS',
|
||||||
'GCC_PREPROCESSOR_DEFINITIONS' => 'USE_FRAMEWORKS=1' }
|
'GCC_PREPROCESSOR_DEFINITIONS' => 'USE_FRAMEWORKS=1' }
|
||||||
|
|
||||||
s.dependency "GCDKit", "1.2.6"
|
s.dependency "GCDKit", "1.2.6"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -715,9 +715,28 @@ internal extension CollectionType where Generator.Element == SelectTerm {
|
|||||||
fetchRequest.includesPendingChanges = false
|
fetchRequest.includesPendingChanges = false
|
||||||
fetchRequest.resultType = .DictionaryResultType
|
fetchRequest.resultType = .DictionaryResultType
|
||||||
|
|
||||||
let entityDescription = fetchRequest.entity!
|
func attributeDescriptionForKeyPath(keyPath: String, inEntity entity: NSEntityDescription) -> NSAttributeDescription? {
|
||||||
let propertiesByName = entityDescription.propertiesByName
|
|
||||||
let attributesByName = entityDescription.attributesByName
|
let components = keyPath.componentsSeparatedByString(".")
|
||||||
|
switch components.count {
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
return nil
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
return entity.attributesByName[components[0]]
|
||||||
|
|
||||||
|
default:
|
||||||
|
guard let relationship = entity.relationshipsByName[components[0]] else {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return attributeDescriptionForKeyPath(
|
||||||
|
components.dropFirst().joinWithSeparator("."),
|
||||||
|
inEntity: relationship.entity
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var propertiesToFetch = [AnyObject]()
|
var propertiesToFetch = [AnyObject]()
|
||||||
for term in self {
|
for term in self {
|
||||||
@@ -725,20 +744,22 @@ internal extension CollectionType where Generator.Element == SelectTerm {
|
|||||||
switch term {
|
switch term {
|
||||||
|
|
||||||
case ._Attribute(let keyPath):
|
case ._Attribute(let keyPath):
|
||||||
if let propertyDescription = propertiesByName[keyPath] {
|
let entityDescription = fetchRequest.entity!
|
||||||
|
if let attributeDescription = attributeDescriptionForKeyPath(keyPath, inEntity: entityDescription) {
|
||||||
|
|
||||||
propertiesToFetch.append(propertyDescription)
|
propertiesToFetch.append(attributeDescription)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
CoreStore.log(
|
CoreStore.log(
|
||||||
.Warning,
|
.Warning,
|
||||||
message: "The property \"\(keyPath)\" does not exist in entity \(cs_typeName(entityDescription.managedObjectClassName)) and will be ignored by \(cs_typeName(owner)) query clause."
|
message: "The key path \"\(keyPath)\" could not be resolved in entity \(cs_typeName(entityDescription.managedObjectClassName)) as an attribute and will be ignored by \(cs_typeName(owner)) query clause."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
case ._Aggregate(let function, let keyPath, let alias, let nativeType):
|
case ._Aggregate(let function, let keyPath, let alias, let nativeType):
|
||||||
if let attributeDescription = attributesByName[keyPath] {
|
let entityDescription = fetchRequest.entity!
|
||||||
|
if let attributeDescription = attributeDescriptionForKeyPath(keyPath, inEntity: entityDescription) {
|
||||||
|
|
||||||
let expressionDescription = NSExpressionDescription()
|
let expressionDescription = NSExpressionDescription()
|
||||||
expressionDescription.name = alias
|
expressionDescription.name = alias
|
||||||
@@ -754,14 +775,13 @@ internal extension CollectionType where Generator.Element == SelectTerm {
|
|||||||
forFunction: function,
|
forFunction: function,
|
||||||
arguments: [NSExpression(forKeyPath: keyPath)]
|
arguments: [NSExpression(forKeyPath: keyPath)]
|
||||||
)
|
)
|
||||||
|
|
||||||
propertiesToFetch.append(expressionDescription)
|
propertiesToFetch.append(expressionDescription)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
CoreStore.log(
|
CoreStore.log(
|
||||||
.Warning,
|
.Warning,
|
||||||
message: "The attribute \"\(keyPath)\" does not exist in entity \(cs_typeName(entityDescription.managedObjectClassName)) and will be ignored by \(cs_typeName(owner)) query clause."
|
message: "The key path \"\(keyPath)\" could not be resolved in entity \(cs_typeName(entityDescription.managedObjectClassName)) as an attribute and will be ignored by \(cs_typeName(owner)) query clause."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>FMWK</string>
|
<string>FMWK</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>2.0.2</string>
|
<string>2.0.5</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
|
|||||||
@@ -32,14 +32,10 @@ internal final class NotificationObserver {
|
|||||||
|
|
||||||
// MARK: Public
|
// MARK: Public
|
||||||
|
|
||||||
let notificationName: String
|
|
||||||
let object: AnyObject?
|
|
||||||
let observer: NSObjectProtocol
|
let observer: NSObjectProtocol
|
||||||
|
|
||||||
init(notificationName: String, object: AnyObject?, queue: NSOperationQueue? = nil, closure: (note: NSNotification) -> Void) {
|
init(notificationName: String, object: AnyObject?, queue: NSOperationQueue? = nil, closure: (note: NSNotification) -> Void) {
|
||||||
|
|
||||||
self.notificationName = notificationName
|
|
||||||
self.object = object
|
|
||||||
self.observer = NSNotificationCenter.defaultCenter().addObserverForName(
|
self.observer = NSNotificationCenter.defaultCenter().addObserverForName(
|
||||||
notificationName,
|
notificationName,
|
||||||
object: object,
|
object: object,
|
||||||
@@ -50,10 +46,6 @@ internal final class NotificationObserver {
|
|||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
|
|
||||||
NSNotificationCenter.defaultCenter().removeObserver(
|
NSNotificationCenter.defaultCenter().removeObserver(self.observer)
|
||||||
self.observer,
|
|
||||||
name: self.notificationName,
|
|
||||||
object: self.object
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user