In the area of adding images, this is what it says to do.
Next, you need to pass the image to PDFCreator. Open FlyerBuilderViewController.swift and replace the implementation of prepare(for:sender:)
with:
if
let title = flyerTextEntry.text,
let body = bodyTextView.text,
let image = imagePreview.image {
let pdfCreator = PDFCreator(title: title, body: body,
image: image, contact: "")
vc.documentData = pdfCreator.createFlyer()
}
Here is what I have before replacing with above which compiles.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "previewSegue" {
guard
segue.identifier == "previewSegue",
let vc = segue.destination as? PDFPreviewViewController,
let title = flyerTextEntry.text,
let body = bodyTextView.text
else {
return
}
let pdfCreator = PDFCreator(
title: title,
body: "",
image: UIImage(),
contact: ""
)
vc.documentData = pdfCreator.createFlyer()
}
}
To replace it and make it work you need to leave in the line
let vc = segue.destination as? PDFPreviewViewController,
Which it then should look like this
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if
let vc = segue.destination as? PDFPreviewViewController,
let title = flyerTextEntry.text,
let body = bodyTextView.text,
let image = imagePreview.image {
let pdfCreator = PDFCreator(title: title, body: body,
image: image, contact: "")
vc.documentData = pdfCreator.createFlyer()
}
}
And just a note, the Final file in the downloaded materials looks nothing like the actual completed app.