Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ambiguous use of 'init'

Tags:

swift

I try to initial my class with block (closure) but I got

Ambiguous use of 'init'

enter image description here

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 .

like image 809
Fadi Abuzant Avatar asked Sep 19 '25 17:09

Fadi Abuzant


1 Answers

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

like image 84
Craig Avatar answered Sep 23 '25 11:09

Craig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!