[英]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 )在錯誤部分( https://developer.apple.com/documentation/corenfc/nfcreadererror )上顯示了一堆錯誤代碼。
我希望能夠讀取來自Reader會話的錯誤,並將其放在switch語句中,我可以為每個錯誤輸出不同的消息。 我不知道如何從函數中獲取那些錯誤消息。 我假設我錯過了基本目標c上的某些內容。
我希望得到的是這樣的東西。
switch (error) {
case NFCReaderErrorSecurityViolation:
//Do Stuff
break;
case NFCReaderErrorUnsupportedFeature:
//NFC is unsupported.
break;
//ETC
default:
break;
}
我怎么得到的?
如下所示在switch塊中使用error.code
,
switch (error.code) {
case NFCReaderErrorSecurityViolation:
//Do Stuff
break;
case NFCReaderErrorUnsupportedFeature:
//NFC is unsupported.
break;
//ETC
default:
break;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.