This is my init
:
extension NSNumberFormatter {
convenience init(digits: Int = 0) {
self.init() //ambiguous reference to member 'NSNumberFormatter.init'
groupingSeparator = " "
decimalSeparator = "."
numberStyle = .DecimalStyle
roundingMode = .RoundHalfDown
maximumFractionDigits = digits
minimumFractionDigits = digits
}
}
What is the reason?
The same problem is when I put self.init()
at the end of my convenience initializer.
The reason is that you have created a new init
that can be called without any parameters since digits
has a default value of 0
. So now, init()
can refer to the default initializer or your new one. If you remove the default value for digits
, it will then compile.
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