---
title: "IOSurfaceUnlock(_:_:_:)"
framework: IOSurface
role: symbol
role_heading: Function
platforms: [iOS 11.0+, iPadOS 11.0+, Mac Catalyst 13.1+, macOS 10.6+, tvOS 11.0+, visionOS 1.0+]
path: "iosurface/iosurfaceunlock(_:_:_:)"
---

# IOSurfaceUnlock(_:_:_:)

“Unlock” an IOSurface for reading or writing.

## Declaration

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

## Discussion

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 data. If the seed parameter is non-NULL, 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(_:_:_:), 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 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.

## See Also

### Functions

- [IOSurfaceAlignProperty(_:_:)](iosurface/iosurfacealignproperty(_:_:).md)
- [IOSurfaceAllowsPixelSizeCasting(_:)](iosurface/iosurfaceallowspixelsizecasting(_:).md)
- [IOSurfaceCopyAllValues(_:)](iosurface/iosurfacecopyallvalues(_:).md)
- [IOSurfaceCopyValue(_:_:)](iosurface/iosurfacecopyvalue(_:_:).md)
- [IOSurfaceCreate(_:)](iosurface/iosurfacecreate(_:).md)
- [IOSurfaceCreateMachPort(_:)](iosurface/iosurfacecreatemachport(_:).md)
- [IOSurfaceCreateXPCObject(_:)](iosurface/iosurfacecreatexpcobject(_:).md)
- [IOSurfaceDecrementUseCount(_:)](iosurface/iosurfacedecrementusecount(_:).md)
- [IOSurfaceGetAllocSize(_:)](iosurface/iosurfacegetallocsize(_:).md)
- [IOSurfaceGetBaseAddress(_:)](iosurface/iosurfacegetbaseaddress(_:).md)
- [IOSurfaceGetBaseAddressOfPlane(_:_:)](iosurface/iosurfacegetbaseaddressofplane(_:_:).md)
- [IOSurfaceGetBitDepthOfComponentOfPlane(_:_:_:)](iosurface/iosurfacegetbitdepthofcomponentofplane(_:_:_:).md)
- [IOSurfaceGetBitOffsetOfComponentOfPlane(_:_:_:)](iosurface/iosurfacegetbitoffsetofcomponentofplane(_:_:_:).md)
- [IOSurfaceGetBytesPerElement(_:)](iosurface/iosurfacegetbytesperelement(_:).md)
- [IOSurfaceGetBytesPerElementOfPlane(_:_:)](iosurface/iosurfacegetbytesperelementofplane(_:_:).md)
