【发布时间】:2017-08-28 04:06:57
【问题描述】:
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;
}
我如何得到它?
【问题讨论】:
标签: ios objective-c iphone xcode core-nfc