Dynamic font size for NSTextField on macOS

On iOS I can create a UIFont that automatically adapts to the font size chosen in the Settings app by the user:

label.font = UIFont.preferredFont(forTextStyle: .body)
label.adjustsFontForContentSizeCategory = true

(Copy-pasted from here.) I couldn't find a similar API for macOS. In the Accessibility settings I can change the font size and some apps react to it, like System Settings and Finder automatically increase the labels. Is there a way to create NSFont or NSTextField that automatically adapts to the chosen font size?

Dynamic font size for NSTextField on macOS
 
 
Q