---
title: "writeNDEF(_:completionHandler:)"
framework: corenfc
role: symbol
role_heading: Instance Method
path: "corenfc/nfcndeftag/writendef(_:completionhandler:)"
---

# writeNDEF(_:completionHandler:)

Saves an NDEF message to a writable tag.

## Declaration

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

```swift
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 doc://com.apple.corenfc/documentation/CoreNFC/NFCNDEFReaderSession. The handler has the following parameter:

## Discussion

Discussion To determine whether the tag is writable, call queryNDEFStatus(completionHandler:) and check that the status is NFCNDEFStatus.readWrite.

## See Also

### Writing to the Tag

- [writeLock(completionHandler:)](corenfc/nfcndeftag/writelock(completionhandler:).md)
