嘿 @mjheitz. ， 我很高兴你喜欢它！你不必担心在这里听起来朴素，即使你是一名经验丰富的迅速开发人员 - 我们都总是在一起。
You should be able to mimic the same thing going on in the tutorial for this. I used
Location as a very simple model to write to the devices, but you can replace the references to this with your own
Codable type (the protocol your type conforms to to make encoding/decoding easier). It still needs to be saved to the tag using
NFCNDEFPayload. When you read the tag, you’ll just attempt to decode the records. Note that an NFC tag can save multiple records in the payload, and this tutorial assumed you would only ever have one value in the payload array.
Writing to a tag requires you to connect to a tag and call
writeNDEF(_:). You can just leave out the steps it takes to get to this point in your client code. You’ll need to have some way to initially write your data, and this tutorial attempts to break out that concept with the “Admin” tab. It also writes to the tag when the user “updates” the location, but you can also ignore that for your use case.
To perform an action when a tag is read, you can take a look at
readLocation(from:) in the sample code. This calls
readNDEF(_:) on the tag. Once a tag is successfully read, you can swap out this code to do whatever you need.
可编码教程 Even though it’s a year old, it is still perfectly relevant if you’re not familiar or comfortable with