NSManagedObject associatedtype has no member 'fetchRequest' in Xcode 13

Viewed 252

After upgrading to Xcode 13, I am seeing compilation issues with the below code:

public protocol CoreDataFetchable {
    associatedtype FetchableObject: NSManagedObject

    static func fetchFromCoreData(withPredicate predicate: NSPredicate?) -> Array<Self>
}

extension CoreDataFetchable {
    
    static public func fetchFromCoreData(withPredicate predicate: NSPredicate? = nil) -> Array<Self> {
        let context = ...
        let fetchRequest = FetchableObject.fetchRequest()
        ...
        return [Self]()
    }
}

The following line: let fetchRequest = FetchableObject.fetchRequest() results in the following compilation error message: Type 'Self.FetchableObject' has no member 'fetchRequest'

If anyone has any insight into this I'd be much obliged :)

0 Answers
Related