---
title: updateLayer()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nsview/updatelayer()
---

# updateLayer()

Updates the view’s content by modifying its underlying layer.

## Declaration

```swift
func updateLayer()
```

## Discussion

Discussion You use this method to optimize the rendering of your view in situations where you can represent your views contents entirely using a layer object. If your view’s wantsUpdateLayer property is true, the view calls this method instead of draw(_:) during the view update cycle. Custom views can override this method and use it to modify the properties of the underlying layer object. Modifying layer properties is a much more efficient way to update your view than is redrawing its content each time something changes. When you want to update the contents of your layer, mark the view as dirty by setting its needsDisplay property to true. Doing so adds the view to the list of views that need to be refreshed during the next update cycle. During that update cycle, this method is called if the wantsUpdateLayer property is still true. Your implementation of this method should not call super. This method supports automatic observation tracking. For more information, see Updating views automatically with observation tracking.

## See Also

### Related Documentation

- [wantsUpdateLayer](appkit/nsview/wantsupdatelayer.md)

### Observing data in views

- [Updating views automatically with observation tracking](appkit/updating-views-automatically-with-observation-tracking.md)
- [layout()](appkit/nsview/layout().md)
- [updateConstraints()](appkit/nsview/updateconstraints().md)
- [draw(_:)](appkit/nsview/draw(_:).md)
