Expression Implicitly Coerced from 'String' to Any

Swift Expression implicitly coerced from 'Any??' to 'Any?'

The value of your dictionary is Any?. The result of accessing a dictionary value is an optional because the key might not exist. So you end up with Any??.

There's really no need for your dictionary to be declared to have optional values.

Change it to [String: Any]? and your issue goes away.

warning: expression implicitly coerced from 'String?' to Any

This warning occurs when you print an optional. The compiler suggests three options to silence the warning. Use the most appropriate one. The warning is harmless.

Swift 3: Expression implicitly coerced from 'UIView?' to Any

In my case it was an issue related to a dictionary without explicit type:

let dict = ["key": value]

Than I solved specifying the type:

let dict: [String: Any] = ["key": value]

In your case you can specify your value type:

let dict: [String: UIView] = ["key": value]


Related Topics



Leave a reply



Submit