<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/PropertyListSerialization/writePropertyList(_:to:format:options:error:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPropertyListSerialization(cm)writePropertyList:toStream:format:options:error:"
  },
  "title" : "writePropertyList(_:to:format:options:error:)"
}
-->

# writePropertyList(_:to:format:options:error:)

Writes a property list to the specified stream.

```
class func writePropertyList(_ plist: Any, to stream: OutputStream, format: PropertyListSerialization.PropertyListFormat, options opt: PropertyListSerialization.WriteOptions, error: NSErrorPointer) -> Int
```

## Parameters

`plist`

The property list that you want to write out.

`stream`

An [`OutputStream`](/documentation/Foundation/OutputStream) instance that is open and ready to receive the property list data.

`format`

One of the property list formats defined in [`PropertyListSerialization.PropertyListFormat`](/documentation/Foundation/PropertyListSerialization/PropertyListFormat).

`opt`

Currently unused. Set to `0`.

`error`

A pointer that the function may set to an [`NSError`](/documentation/Foundation/NSError) object when an error occurs to provide additional information about the error.

## Return Value

The number of bytes written to the stream. A return value of `0` indicates that an error occurred.

---

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)