Totka Totka - 4 months ago 12
iOS Question

Alamofire conflict with SugarRecord?

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?

Answer

you can fix this disambiguation adding the name module SugarRecord.

albums = try! db.fetch(SugarRecord.Request<CDAlbum>())
Comments