If you intend to use more than one view controller in the extension storyboard, you will need to pass a link to the extensionContext original view controller to the view controller, which will ultimately be responsible for completing the extension request. In the initial view controller:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { let destination = segue.destinationViewController as! FinalViewController destination.originalExtensionContext = self.extensionContext }
And in your final controller:
@IBAction func dismissController(sender: UIButton!) { dismissViewControllerAnimated(true) { () -> Void in self.originalExtensionContext.completeRequestReturningItems(self.originalExtensionContext.inputItems, completionHandler: nil) }
Note that you need to create a property with a unique name for the original extension context, since extensionContext already exists as the property name in the superclass of UIViewController . You cannot pass an existing extensionContext to the UIViewController extensionContext property, as it is a read-only attribute.
source share