In my project I download some data using Alamofire, the I need to save them with CoreData, using SugarRecord, but I get a strange error when I fetch my entities, like this:
var albums: [CDAlbum]
do {
albums = try! db.fetch(Request<CDAlbum>())
} catch {
// TODO: handle errors as appropriate
print("ERROR FETCHING ALBUMs")
}
I get a red dot that say "Cannot specialize non-generic type 'Request'"
Now, if I click on "Request", Xcode redirect me to Alamofire folder>Request.swift, but I need the method from SugarRecord>CoreData>NSManagedObjectContext.swift called
public func fetch<T: Entity>(request: Request<T>) throws -> [T] {}
It seems that Xcode confuse the two methods. How could I solve?
答案 0 :(得分:1)
您可以修复此消除歧义,添加名称模块SugarRecord.
albums = try! db.fetch(SugarRecord.Request<CDAlbum>())
答案 1 :(得分:0)
我解决了下载Alamofire(之前由cocoapods安装)并将Request类重命名为Requeste的问题。