1

It is possible the user would start editing a photo with my Photo Editing Extension, then they could close the app (Photos) only to return to it later. I am wondering how to handle changes to that asset. In the template, Apple doesn't handle any changes. What happens if that asset doesn't exist anymore - it was deleted on a different device, or that asset has been edited since it was opened? If it was deleted it should probably Cancel the extension, if it was changed it simply needs to update the preview image.

Not only should I handle asset changes, I also need to handle changes to the default settings I allow the user to change in the main app, as that will affect the photo preview that's rendered in the extension. I thought I could simply detect when the user returns to Photos (the extension comes to the foreground) and then update the preview, and this would handle the case where the photo has changed and the app's settings have changed (but I'm not sure what would happen if the asset doesn't exist anymore). Unfortunately, this code doesn't call the function when you close the app (Photos with extension visible) and return to it:

override func viewWillAppear(animated: Bool) {
    super.viewWillAppear(animated)

    NSNotificationCenter.defaultCenter().addObserver(self, selector: "willBeResumed", name: UIApplicationWillEnterForegroundNotification, object: nil)
}

func willBeResumed() {
    updatePhotoPreview() //doesn't get here
}

How can I handle asset changes as well as changes made to my app's settings so that I can ensure the preview displayed is always accurate upon returning to the extension when Photos was closed with the extension still on screen?

Jordan H
  • 52,571
  • 37
  • 201
  • 351

0 Answers0