I'm having some serious issues here trying to save a
You can't easily save
AVMetadataMachineReadableCodeObject to Core Data, because it's not a supported type and does not conform to
NSCoding. Switching to Realm won't make any difference, because it has the same restrictions (it can't just save an
AVMetadataMachineReadableCodeObject). The reasons are similar-- in both cases
AVMetadataMachineReadableCodeObject isn't a subclass of the appropriate type, and it's not one of the supported property types.
What you need to do depends on how exactly your scan history UI is supposed to look. Saving the
AVMetadataMachineReadableCodeObject is almost certainly not the best approach, though (you might be able to add
NSCoding through a Swift extension but it's probably the wrong answer even if it works). There are a couple of possibilities:
AVMetadataMachineReadableCodeObject. When you want to show the scan history, generate new images to display. This is straightforward using Core Image--
CIPDF417BarcodeGeneratorare all built in.
stringValueof the scanned code in the UI so that people can see what the image represents.