Hi,
After a painful migration to Swift 3, i'm facing a last problem.
I have an ObjC Object and an ObjC Protocol that have the same name (and i can't rename it, it's generated code).
This works fine in ObjC, but not in swift "XXX is ambigous for type lookup in this context"
Here is an Example :
// Objc file Operation.h
@interface Operation: NSObject {
NSString* _name;
}
@end// Objc file Service.h
@protocol Operation <NSObject>
- (void)doSomething
@end// Swift File
var operation: Operation! <-This produce an error : 'Operation' is ambiguous for type lookup in this contextIs it possible to specify the type of operation ?
Many thanks
Ben
It's not because your class and protocol are having the same name, but because your class has the same name as the one in Foundation.
Swift 3 imports Objective-C class `NSOperation` with renaming it to `Operation`, so it's confliction with your `Operation`.
And your protocol `Operation` is imported as `OperationProtocol` as well as the protocol `NSObject` is imported as `NSObjectProtocol`.
You can use 3 `Operation`s in your code like this:
var nsOperation: Foundation.Operation!
var myOperation: YourProductModuleName.Operation!
var operationProtocol: OperationProtocol!