<!--
{
  "availability" : [
    "macOS: 15.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FSKit",
  "identifier" : "/documentation/FSKit/FSBlockDeviceResource/writeFrom:startingAt:length:error:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "FSKit"
    ],
    "preciseIdentifier" : "c:objc(cs)FSBlockDeviceResource(im)writeFrom:startingAt:length:error:"
  },
  "title" : "writeFrom:startingAt:length:error:"
}
-->

# writeFrom:startingAt:length:error:

Synchronously writes data from from a buffer to the resource and executes a block afterwards.

```
- (size_t) writeFrom:(void *) buffer startingAt:(off_t) offset length:(size_t) length error:(NSError **) error;
```

## Parameters

`buffer`

A buffer to provide the data.

`offset`

The offset into the resource from which to start writing.

`length`

A maximum number of bytes to write. The completion handler receives a parameter with the actual number of bytes write.

`error`

On return, any error encountered while writing data, or `nil` if no error occurred.

## Return Value

The actual number of bytes written.

## Discussion

This is a synchronous version of [`writeFrom:startingAt:length:completionHandler:`](/documentation/FSKit/FSBlockDeviceResource/writeFrom:startingAt:length:completionHandler:).

> Note: In some cases, this method performs a partial write. In this case, the return value is shorter than the requested length, and the `error` is set to `nil`.

---

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)