Contents

currentDrawable

The drawable to use for the current frame.

Declaration

var currentDrawable: (any CAMetalDrawable)? { get }

Discussion

If all drawable objects are in use, the value of this property is nil. Your app should check that currentDrawable isn’t nil before attempting to draw. The view changes the value of this property only after returning from a drawing function, either draw(_:) from a subclassed instance of the view, or draw(in:) from the view’s delegate.

Use a MTLRenderCommandEncoder object to render into the drawable’s texture and present it for display (typically registered using the present(_:) method of a command buffer). Try to minimize the time between when you fetch the drawable and when you submit the command buffer that uses it. For more information, see CAMetalLayer.

See Also

Retrieving Render Target Information