Creating Objective-C function that checks when headphones are plugged/unplugged on MacOS

Hello! I need assistance writing an Objective-C function that can interface with the game engine Unity and listen for changes in built-in output and see if headphones are or are not currently connected to a Mac device.

Creating Objective-C function that checks when headphones are plugged/unplugged on MacOS
 
 
Q