对于以下错误,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)在错误部分(https://developer.apple.com/documentation/corenfc/nfcreadererror)上显示了一组错误代码。
我希望能够读取来自阅读器会话的错误,并将其放在switch语句中,这样我就可以为每个错误输出不同的消息。我不知道如何从函数中获取这些错误消息。我假设我遗漏了一些关于投射的基本目标c的东西。
我希望得到的是这样的东西。
switch (error) {
case NFCReaderErrorSecurityViolation:
//Do Stuff
break;
case NFCReaderErrorUnsupportedFeature:
//NFC is unsupported.
break;
//ETC
default:
break;
}我该怎么做呢?
发布于 2017-08-28 13:23:47
在开关块中使用error.code,如下所示:
switch (error.code) {
case NFCReaderErrorSecurityViolation:
//Do Stuff
break;
case NFCReaderErrorUnsupportedFeature:
//NFC is unsupported.
break;
//ETC
default:
break;
}https://stackoverflow.com/questions/45911674
复制相似问题