<!--
{
  "availability" : [
    "macOS: 14.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MediaExtension",
  "identifier" : "/documentation/MediaExtension/MESampleCursor/sampleLocation()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MediaExtension"
    ],
    "preciseIdentifier" : "c:objc(pl)MESampleCursor(im)sampleLocationReturningError:"
  },
  "title" : "sampleLocation()"
}
-->

# sampleLocation()

Returns the location and byte source of the sample indicated by the cursor.

```
optional func sampleLocation() throws -> MESampleLocation
```

## Return Value

A sample location.

## Discussion

Sample data needs to be contiguous. If the sample data isn’t contiguous or the cursor doesn’t support this method, it fails with the error [`MEError.Code.locationNotAvailable`](/documentation/MediaExtension/MEError-swift.struct/Code/locationNotAvailable). In this case, use [`loadSampleBufferContainingSamples(to:completionHandler:)`](/documentation/MediaExtension/MESampleCursor/loadSampleBufferContainingSamples(to:completionHandler:)) to load the data.

If it’s not possible to implement this method, implement [`estimatedSampleLocation()`](/documentation/MediaExtension/MESampleCursor/estimatedSampleLocation()) to get an estimated sample location, and [`refineSampleLocation(_:refinementData:refinementDataLength:refinedLocation:)`](/documentation/MediaExtension/MESampleCursor/refineSampleLocation(_:refinementData:refinementDataLength:refinedLocation:)) to analyze this data and provide precise location and size info.

---

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)