davelee
(David Lawrence)
1
I'm attempting to extend NSFetchRequest to conform to a more abstract protocol, as shown below. But doing so results in the error "Extension of a generic Objective-C class cannot access the class's generic parameters at runtime".
I realize that the Core Data is an Objective-C library, and that NSFetchRequest is generic, but I don't understand how to work around this error. I'm running Xcode 10.2 & Swift 4.2.
import Foundation
import CoreData
protocol Request {
var from: String? {get}
}
extension NSFetchRequest: Request {
var from: String? {
get {
return self.entityName
}
}
}
3 Likes