40.4 Modifying the ImageDocDemoDocument.swift File
Although we have changed the type identifiers to support images instead of plain text, the document declaration is still implemented for handling text-based content. Select the ImageDocDemoDocument.swift file to load it into the editor and begin by modifying the UTType extension so that it reads as follows:
extension UTType {
static var exampleImage: UTType {
UTType(importedAs: "com.ebookfrenzy.image")
}
}
Next, locate the readableContentTypes variable and modify it to use the new UTType:
static var readableContentTypes: [UTType] { [.exampleImage] }
With the necessary type changes made, the next step is to modify the structure to work with images instead of string data. Remaining in the ImageDocDemoDocument.swift file, change the text variable from a string to an image and modify the first initializer to...