I try to initial my class with block (closure) but I got
Ambiguous use of 'init'
all the time, my class in objective c and I try to use it in swift4
Objc init
typedef void (^updateCoordinate)(CLLocationCoordinate2D coordinate);
- (instancetype)initWithCoordinate:(CLLocationCoordinate2D)coordinate Dragable:(BOOL)isDragable updateCoordinate:(updateCoordinate)updateCoordinate;
Swift init
let map = FAMapViewController.init(coordinate: CLLocationCoordinate2DMake(0, 0), dragable: true) { (coordinate) in }
NS_SWIFT_NAME
does not help me, I got same issue any advice Please .
Ambiguous use of 'init'
means the signature of the init
call you're making in your Swift can't be matched to an init
in the target class.
I've seen this error caused by simple mistakes in the call site - like capitalisation being incorrect. For example in your Swift init
call you have a lowercase dragable: true
but in the Objc init you have Dragable:(BOOL)
StackOverflow is full of examples of incorrect capitalisation, e.g.:
IOS: Ambiguous Use of init(CGImage)
SCNSceneSource init is giving Ambiguous use of 'init(URL:options:)' error
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