In swift 2 I'm using CNLabeledValue.localizedStringForLabel(phoneNumber.label)
and works fine.
In swift 3 I tried this line CNLabeledValue.localizedString(forLabel: phoneNumber.label!)
but got generic parameter 'ValueType' could not be inferred
error
How to get localizedstring for CNLabeledValue in swift3?
In Swift 3,
CNLabeledValue
is declared as:It's a generic type and if you use it in a proper context, you have no need to to cast its
value
. Swift 3 well infers theValueType
.But in your code, Swift has no clue to infer the
ValueType
. It is sort of annoying, becauseValueType
is needless while executing the type method. But the type system of Swift needs it to be specified. If Swift cannot infer the type of theValueType
, you can explicitly give it.Try this: