<!--
{
  "availability" : [
    "iOS: 10.3.0 -",
    "iPadOS: 10.3.0 -",
    "macCatalyst: 13.4.0 -",
    "macOS: 10.15.4 -",
    "tvOS: 10.2.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLDrawable/addPresentedHandler(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(pl)MTLDrawable(im)addPresentedHandler:"
  },
  "title" : "addPresentedHandler(_:)"
}
-->

# addPresentedHandler(_:)

Registers a block of code to be called immediately after the drawable is presented.

```
func addPresentedHandler(_ block: @escaping MTLDrawablePresentedHandler)
```

## Parameters

`block`

A block of code to be invoked.

## Discussion

You can register multiple handlers for a single drawable object.

The following example code schedules a presentation handler that reads the [`presentedTime`](/documentation/Metal/MTLDrawable/presentedTime) property and uses it to derive the interval between the last and current presentation times. From that information, it determines the app’s frame rate.

```objective-c
// Property declarations
@property (nonatomic) CFTimeInterval previousPresentedTime;
/* ... */
// Render loop
__block Renderer *strongSelf = self;
[view.currentDrawable addPresentedHandler:^(id<MTLDrawable> drawable) {
    CFTimeInterval presentationDuration = drawable.presentedTime - strongSelf.previousPresentedTime;
    CFTimeInterval frameRate = 1.0/presentationDuration;
    /* ... */
    strongSelf.previousPresentedTime = drawable.presentedTime;
}];
```

---

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)