Skip to content

Commit f70e4d5

Browse files
armandzwanpeterringset
authored andcommitted
Making it possible to use UUID as Identifier.
1 parent ccf2a1f commit f70e4d5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CoreDataCodable/FetchableManageObject.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Foundation
1212
public protocol FetchableManagedObject {
1313

1414
associatedtype FetchableCodingKeys: CodingKey
15-
associatedtype Identifier: Decodable & CVarArg
15+
associatedtype Identifier: Decodable
1616
static var identifierKey: FetchableCodingKeys { get }
1717

1818
}
@@ -24,7 +24,7 @@ extension FetchableManagedObject where Self: NSManagedObject {
2424
let container = try decoder.container(keyedBy: FetchableCodingKeys.self)
2525
let identifier = try container.decode(Identifier.self, forKey: identifierKey)
2626
let request = NSFetchRequest<Self>(entityName: String(describing: Self.self))
27-
request.predicate = NSPredicate(format: "\(identifierKey.stringValue) = %@", identifier)
27+
request.predicate = NSPredicate(format: "%K == %@", argumentArray:[identifierKey.stringValue, identifier])
2828
return try context.fetch(request).first
2929
}
3030

0 commit comments

Comments
 (0)