How do you convert an iPhone OSStatus code to something useful?

前端 未结 19 1523
执念已碎
执念已碎 2020-12-05 01:45

I am getting more than a little sick of this iPhone SDK and its documentation...

I am calling AudioConverterNew

in the documentation under Returns: it says \

19条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 02:15

    I combined a few answers. Actually I were looking something like „throw errorForStatusCode(status)”. But in the end achieved:

        guard status == errSecSuccess else {
            throw  NSError(domain: NSOSStatusErrorDomain, code: Int(status), userInfo: [NSLocalizedDescriptionKey: SecCopyErrorMessageString(status, nil) ?? "Undefined error"])
        }
    

    SecCopyErrorMessageString is available from iOS 11.3 https://developer.apple.com/documentation/security/1542001-security_framework_result_codes

提交回复
热议问题