I want to update my app for iOS 11, and have this issue. This is my current code:
protocol DataSourceDelegate: class {
associatedtype Object
func cellIdentifierForObject(object: Object) -> String
func swipeToDeleteObject(object: Object)
}
This protocol is used in one of my view controller:
extension TransactionsViewController: DataSourceDelegate {
func cellIdentifierForObject(object: Object) -> String {
return "Cell"
}
func swipeToDeleteObject(object: Object) {
object.managedObjectContext?.performChanges {
object.managedObjectContext?.delete(object)
}
}
}
Now I get this error for the Object
type:
'Object' is ambiguous for type lookup in this context
On this line:
func cellIdentifierForObject(object: Object) -> String { ... }
For my this issue appears because there are some other Object type in my project. I tried to put the protocol or class name in front of the name, but I still get error.
In my case, I had this ambiguity because the class was declared in a swift file and also being auto-generated by my data model.
If you already declare your class in a swift file, then make sure the code generation is disabled for it.