Ios 展开ViewController之前的验证

Ios 展开ViewController之前的验证,ios,swift,segue,Ios,Swift,Segue,是否有方法在展开ViewController之前进行验证 我有我的ViewController1,还有一个展开功能 @IBAction func unwind(segue: UIStoryboardSegue) { // make stuff with data } ViewController2中的一个按钮与该展开函数相连接,我将数据从ViewController2传递到覆盖函数prepareforsgue中的ViewController1(segue:UIStory

是否有方法在展开ViewController之前进行验证

我有我的ViewController1,还有一个展开功能

    @IBAction func unwind(segue: UIStoryboardSegue) {

       // make stuff with data
}
ViewController2中的一个按钮与该展开函数相连接,我将数据从ViewController2传递到
覆盖函数prepareforsgue中的ViewController1(segue:UIStoryboardSegue,sender:AnyObject?
一切正常,但我想做一些验证

if sender as? UIBarButtonItem == self.saveButton  {

        if let content = self.textFieldContent.text {
            publish.content = content
            publish.image = self.image
        } else { 
           self.alertMessage("Content is empty")
        }

    }
会出现
self.alertMessage()
函数,但每次都会关闭ViewController2。我不希望发生这种情况,我如何才能做到这一点呢?

如果需要防止在某些情况下解除锁定,请使用-(BOOL)shouldPerformSegueWithIdentifier:(NSString*)identifier sender:(id)sender方法