Error in setImage (p254)

In ImageStore.swift I tried to add the following function;

if let data = UIImageJPEGRepresentation(image, 0.5) {
        data.writeToURL(imageURL, atomically: true) 

however it will not work in swift 3. I wrote:

if let data = UIImageJPEGRepresentation(image, 0.5) {
        data.write(to: imageURL as URL, options: .atomicWrite)

however this gives the error "can call throw, but is not marked with ‘try’ and the error is not handled"
and the code gives an error.

If anyone could lend a hand I’d be very grateful! :slight_smile:

Disaster averted, turns out the next few pages explain the error handling with a try/catch block.