iOS 11 CoreNFC如何处理读取错误?

iOS 11 CoreNFC How Does One Handle Reading Errors?

CoreNFC 有一个错误的委托方法:

//Called when the NFC session invalidates with an error.
- (void)readerSession:(nonnull NFCNDEFReaderSession *)session didInvalidateWithError:(nonnull NSError *)error {
}

文档(https://developer.apple.com/documentation/corenfc) shows on the error section (https://developer.apple.com/documentation/corenfc/nfcreadererror)一堆错误代码。

我希望能够读取来自 reader 会话的错误并将其放入 switch 语句中,以便我可以针对每个错误输出不同的消息。我不知道如何从函数中获取这些错误消息。我假设我错过了一些基本的 objective c 投射的东西。

我希望得到的是这样的东西

switch (error) {
        case NFCReaderErrorSecurityViolation:
            //Do Stuff
            break;
        case NFCReaderErrorUnsupportedFeature:
            //NFC is unsupported.
            break;
        //ETC
        default:
            break;
    }

我如何获得它?

在开关块中使用error.code如下,

switch (error.code) {
    case NFCReaderErrorSecurityViolation:
        //Do Stuff
        break;
    case NFCReaderErrorUnsupportedFeature:
        //NFC is unsupported.
        break;
    //ETC
    default:
        break;
}