How do I record a maker note or user comment in EXIF?

I'm building a camera app, and want to record in the EXIF the settings that the user selected. Most settings have standard fields, but one doesn't, so I thought I'll record it in the maker notes field.

I tried

let attachments = NSMutableDictionary(dictionary: CMCopyDictionaryOfAttachments(nil, buffer, kCMAttachmentMode_ShouldPropagate) as! NSDictionary)
let exif = NSMutableDictionary(dictionary: attachments[kCGImagePropertyExifDictionary] as! NSDictionary)
exif[kCGImagePropertyExifMakerNote] = "Blah blah"
attachments[kCGImagePropertyExifDictionary] = exif

But when I try

exiftool photo.JPG | grep -i maker

or

exiftool photo.JPG | grep -i blah

I don't see the note. All other properties I set in EXIF are showing up.


I then tried setting it as a user comment, as suggested in this answer:

let comment = ["My custom setting": "blah"]  exif[kCGImagePropertyExifUserComment] = comment

This doesn't work either.



Am I setting the format of the maker note wrong? Isn't it a string? What about the user comment?


Or is there some other field in EXIF that I should be using instead of maker notes or user comment?