<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "IOSurface",
  "identifier" : "/documentation/IOSurface/IOSurfaceUnlock(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "IOSurface"
    ],
    "preciseIdentifier" : "c:@F@IOSurfaceUnlock"
  },
  "title" : "IOSurfaceUnlock(_:_:_:)"
}
-->

# IOSurfaceUnlock(_:_:_:)

“Unlock” an [`IOSurface`](/documentation/IOSurface/IOSurface) for reading or writing.

```
func IOSurfaceUnlock(_ buffer: IOSurfaceRef, _ options: IOSurfaceLockOptions, _ seed: UnsafeMutablePointer<UInt32>?) -> kern_return_t
```

## Discussion

The term “lock” is used loosely in this context, and is used along with the “unlock” information to put a bound on CPU access to the raw [`IOSurface`](/documentation/IOSurface/IOSurface) data.

If the seed parameter is non-NULL, [`IOSurfaceLock(_:_:_:)`](/documentation/IOSurface/IOSurfaceLock(_:_:_:)) will store the buffer’s internal modification seed value at the time you made the lock call. You can compare this value to a value returned previously to determine of the contents of the buffer has been changed since the last lock.

In the case of [`IOSurfaceUnlock(_:_:_:)`](/documentation/IOSurface/IOSurfaceUnlock(_:_:_:)), the seed value returned will be the internal seed value at the time of the unlock. If you locked the buffer for writing, this value will be incremented as the unlock is performed and the new value will be returned.

See the kIOSurfaceLock enums for more information.

> Note:
> Locking and unlocking an ``doc://com.apple.iosurface/documentation/IOSurface/IOSurface`` is not a particularly cheap operation, so care should be taken to avoid the calls whenever possible. The seed values are particularly useful for keeping a cache of the buffer contents.

---

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)