Totka Totka - 1 year ago 118
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

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 Source

you can fix this disambiguation adding the name module SugarRecord.

albums = try! db.fetch(SugarRecord.Request<CDAlbum>())
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download