From cd0adb75a9370646c1fb7a9d9fb38bbe975ff765 Mon Sep 17 00:00:00 2001 From: Jari Kalinainen Date: Tue, 10 Oct 2017 07:12:01 +0300 Subject: [PATCH] readme update --- README.md | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a1f83c2..c2f3d4a 100644 --- a/README.md +++ b/README.md @@ -21,24 +21,30 @@ pod 'NFCNDEFParse' ## Usage +Import the library. + ``` import NFCNDEFParse +``` -... +Create array for the messages -var data: NDEFMessageWithWellKnownTypes? +``` +var data: [NDEFMessageWithWellKnownTypes] = [] +``` -... +In CoreNFC callback create the "well know types" data array. +``` func readerSession(_ session: NFCNDEFReaderSession, didDetectNDEFs messages: [NFCNDEFMessage]) { - for message in messages { - data = NDEFMessageWithWellKnownTypes(records: message.records) - } + data = messages.flatMap({ NDEFMessageWithWellKnownTypes(records: $0.records) }) } +``` -... +Loop through the data array to print out the values. -data?.records.forEach({ record in +``` +data.records.forEach({ record in if record.type == .text, let record = record as? NFCForumWellKnownTypeTextProtocol { print(record.string) print(record.locale)