# `GSLayer layerDataFromDict:format:error:`

*Type Method*

Encodes layer elements as Glyphs property-list data.

## Declaration

```swift
class func layerData(fromDict dict: [String : Any], format: GSFormatVersion) throws -> Data
```

```objc
+ (NSData *) layerDataFromDict:(NSDictionary<NSString *,id> *) dict format:(GSFormatVersion) format error:(NSError **) error;
```

```python
layerDataFromDict_format_error_(dict: dict[str, object], format: GSFormatVersion) -> tuple[bytes, NSError]
```

## Parameters

- `dict` — A dictionary containing model objects grouped by layer element keys.
- `format` — The Glyphs file format version to use.
- `error` — On failure, information about the error.

## Return Value

The encoded data, or `nil` when an element cannot be encoded.

## See Also

### Encoding

- [`GSLayer propertyListValueFormat:error:`](/Core/GlyphsCore/GSLayer/propertyListValueFormat:error:) — A property-list representation for the specified Glyphs file format version.
- [`GSLayer saveToFile:format:context:error:`](/Core/GlyphsCore/GSLayer/saveToFile:format:context:error:) — Writes the layer in the specified Glyphs file format.
- [`GSLayer attributesDict:`](/Core/GlyphsCore/GSLayer/attributesDict:) — An attribute representation for the specified Glyphs file format version.
- [`GSLayer.readBuffer`](/Core/GlyphsCore/GSLayer/readBuffer) — Values deferred until the layer can complete format-dependent decoding.
- [`GSLayer setReadBuffer:forKey:`](/Core/GlyphsCore/GSLayer/setReadBuffer:forKey:) — Stores a value for format-dependent decoding after the layer hierarchy is available.
- [`GSLayer postRead:format:`](/Core/GlyphsCore/GSLayer/postRead:format:) — Completes format-dependent decoding after the layer has been attached to its object hierarchy.

