---
title: "writePropertyList(_:to:format:options:error:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/propertylistserialization/writepropertylist(_:to:format:options:error:)"
---

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

Writes a property list to the specified stream.

## Declaration

```swift
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 doc://com.apple.foundation/documentation/Foundation/OutputStream instance that is open and ready to receive the property list data.
- `format`: One of the property list formats defined in doc://com.apple.foundation/documentation/Foundation/PropertyListSerialization/PropertyListFormat.
- `opt`: Currently unused. Set to 0.
- `error`: A pointer that the function may set to an doc://com.apple.foundation/documentation/Foundation/NSError object when an error occurs to provide additional information about the error.

## Return Value

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

## See Also

### Serializing a Property List

- [data(fromPropertyList:format:options:)](foundation/propertylistserialization/data(frompropertylist:format:options:).md)
- [PropertyListSerialization.WriteOptions](foundation/propertylistserialization/writeoptions.md)
