Skip to content

Commit 04f7409

Browse files
committed
cdqiQuery
1 parent 1a8c9d2 commit 04f7409

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CoreDataQueryInterface/Extensions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,4 @@ extension NSManagedObject {
187187
return managedObjectModel.entitiesByName[entityName]!
188188
}
189189
}
190+

CoreDataQueryInterface/Protocols.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ public protocol Entity {
1313
associatedtype CDQIAttribute: EntityAttribute
1414
}
1515

16+
extension Entity where Self: NSManagedObject {
17+
public static func cdqiQuery(managedObjectContext: NSManagedObjectContext? = nil) -> Query<Self, Self> {
18+
var query = Query<Self, Self>()
19+
if let managedObjectContext = managedObjectContext {
20+
query = query.context(managedObjectContext: managedObjectContext)
21+
}
22+
return query
23+
}
24+
}
25+
1626
public protocol Typed {
1727
static var cdqiStaticType: NSAttributeType { get }
1828
var cdqiType: NSAttributeType { get }

0 commit comments

Comments
 (0)