Adds more error handling to macOS code and also updates the code to use more ObjC-appropriate code styling. Variable names have been changed to be more expressive and platform- specific constants are used instead of custom FourCharCodes.