# `GSBaseObject saveToFile:format:context:error:`

*Instance Method*

Writes a Glyphs source representation to a file.

## Declaration

```swift
func save(to file: UnsafeMutablePointer<FILE>, format formatVersion: GSFormatVersion, context: GSSaveContext?) throws
```

```objc
- (BOOL) saveToFile:(FILE *) file format:(GSFormatVersion) formatVersion context:(GSSaveContext *) context error:(NSError **) error;
```

```python
saveToFile_format_context_error_(file: FILE, formatVersion: GSFormatVersion, context: GSSaveContext) -> tuple[bool, NSError]
```

## Parameters

- `file` — An open writable file positioned where the representation is written.
- `formatVersion` — The Glyphs file format version to write.
- `context` — The options and shared state for the save operation, or `nil` when none are required.
- `error` — On failure, an error describing why the representation could not be written.

## Return Value

Whether the object was encoded successfully.

## See Also

### Encoding

- [`GSBaseObject propertyListValueFormat:error:`](/Core/GlyphsCore/GSBaseObject/propertyListValueFormat:error:) — A property-list representation in a Glyphs source format, or `nil` when the object cannot be encoded.

