Kiran Jasvanee Kiran Jasvanee - 1 month ago 34
Swift Question

Cannot convert value of type 'SecTrustResultType' to expected argument type 'UInt32'

Trying run Swift 2.3 code in Xcode 8.0

var result = SecTrustResultType(rawValue: SecTrustResultType.Invalid)

Answer

Invalid is one case of enum SecTrustResultType, but SecTrustResultType(rawValue:) expects a value of the underlying "raw type", in this case UInt32.

So this would compile

var result = SecTrustResultType(rawValue: SecTrustResultType.Invalid.rawValue)

but is just a obfuscated version of the equivalent

// Swift 2.x
var result = SecTrustResultType.Invalid
// Swift 3
var result = SecTrustResultType.invalid