<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreNFC",
  "identifier" : "/documentation/CoreNFC/NFCNDEFTag/writeNDEF(_:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core NFC"
    ],
    "preciseIdentifier" : "c:objc(pl)NFCNDEFTag(im)writeNDEF:completionHandler:"
  },
  "title" : "writeNDEF(_:completionHandler:)"
}
-->

# writeNDEF(_:completionHandler:)

Saves an NDEF message to a writable tag.

```
func writeNDEF(_ ndefMessage: NFCNDEFMessage, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```
func writeNDEF(_ ndefMessage: NFCNDEFMessage) async throws
```

## Parameters

`ndefMessage`

The NDEF message to write to the tag.

`completionHandler`

The handler invoked by the reader session after completing the write request. The session calls `completionHandler` on the dispatch queue provided when creating the [`NFCNDEFReaderSession`](/documentation/CoreNFC/NFCNDEFReaderSession).

    The handler has the following parameter:

- error: An <doc://com.apple.documentation/documentation/Foundation/NSError> object if the write request fails. A value of `nil` indicates that the write was successful.

## Discussion

To determine whether the tag is writable, call [`queryNDEFStatus(completionHandler:)`](/documentation/CoreNFC/NFCNDEFTag/queryNDEFStatus(completionHandler:)) and check that the `status` is [`NFCNDEFStatus.readWrite`](/documentation/CoreNFC/NFCNDEFStatus/readWrite).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)