Instance Property


The drawable to be used for the current frame.


@property(nonatomic, readonly) id<CAMetalDrawable> currentDrawable;


If all drawable objects are in use, the value of this property is nil. Your app should check that currentDrawable is not nil before attempting to draw. The value of this property changes only after returning from one of the drawing functions, either drawRect: from a subclassed instance of the view, or drawInMTKView: from the view’s delegate.

Use a MTLRenderCommandEncoder object to render into the drawable’s texture and present it for display (typically registered via the presentDrawable: 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 example, you might perform other work on the CPU, render to offscreen textures or execute compute passes, then obtain the drawable and encode a command buffer to render to it. After you submit this command buffer, release all strong references to the drawable. A texture can be reused only if it is not onscreen and all strong references to the drawable have been released. If you don’t release drawables correctly, the view will run out of drawables to vend.

See Also

Generated Render Target Objects


A render pass descriptor generated from the current drawable’s texture, the view’s buffers, and the view’s clear values.


A packed depth/stencil texture attached to the currentDrawable object’s texture.


A multisample color sample texture resolved into the currentDrawable object’s texture.