---
title: "IOSurfaceCreateMachPort(_:)"
framework: iosurface
role: symbol
role_heading: Function
path: "iosurface/iosurfacecreatemachport(_:)"
---

# IOSurfaceCreateMachPort(_:)

Returns a mach_port_t that holds a reference to the IOSurface.

## Declaration

```swift
func IOSurfaceCreateMachPort(_ buffer: IOSurfaceRef) -> mach_port_t
```

## Discussion

Discussion This is useful if you need to atomically or securely pass an IOSurface to another task without making the surface global to the entire system. The returned port must be deallocated with mach_port_deallocate or the equivalent. note: Any live mach ports created from an IOSurfaceRef implicitly increase the IOSurface’s global use count by one until the port is deleted.

## See Also

### Functions

- [IOSurfaceAlignProperty(_:_:)](iosurface/iosurfacealignproperty(_:_:).md)
- [IOSurfaceAllowsPixelSizeCasting(_:)](iosurface/iosurfaceallowspixelsizecasting(_:).md)
- [IOSurfaceCopyAllValues(_:)](iosurface/iosurfacecopyallvalues(_:).md)
- [IOSurfaceCopyValue(_:_:)](iosurface/iosurfacecopyvalue(_:_:).md)
- [IOSurfaceCreate(_:)](iosurface/iosurfacecreate(_:).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)
- [IOSurfaceGetBytesPerRow(_:)](iosurface/iosurfacegetbytesperrow(_:).md)
