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.
For me the cause of the error was same name of the Class for two different Cocoapods. If you are integrating pods to your VC, try to delete some of them by clearing 'Import ...' line at the top of your VC file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With