Tag: ndef

iOS 11 – 如何从CoreNFC读取/parsingNDEF消息?

我有一堆标签是URL标签的内容“ http://WEBSITE.com ”。 比方说,WEBSITE是youtube所以http://youtube.com 。 当我在Android等扫描他们,它保持http或https。 我试图用核心NFC框架来扫描这些相同的标签。 我扫描他们,我得到了一堆字节,我用UTF8编码使用NSString的initWithData转换。 我回到\ ^ Cyoutube.com。 我想获得http://youtube.com 。 我怎样才能有效载荷来获得我所需要的? 如果我假设在string前面的http,我该怎么知道它是http还是https甚至是ftp? 编辑1: 我在纯文本logging的下面的答案代码有问题。 当为“hello world”创build文本logging时,我从控制台得到以下输出: 2017-06-09 12:45:35.151806-0400 testNFC [2963:190724]有效负载string: https://www.hehello world 2017-06-09 12:45:35.154959-0400 testNFC [2963:190724]有效载荷数据: <02656e68 656c6c6f 20776f72 6c64> 获取我使用的string NSString * nfcMessage = [nfcType stringByAppendingString:[[[NSString alloc] initWithData:payload.payload encoding:NSUTF8StringEncoding] substringFromIndex:1]]; nfcType是你函数的返回值,但是对于None情况,我返回@“”; 我期待着得到你好世界。