Ios 在Swift中将多个参数传递给UIAlertAction

Ios 在Swift中将多个参数传递给UIAlertAction,ios,swift,uialertaction,Ios,Swift,Uialertaction,我一直在试图找到一种方法,将多个参数传递给UIAlertAction。下面是我的代码。我想将“源”字符串传递给警报的选定操作 我遇到了这样的错误: 无法将类型“()”的值转换为预期的参数类型“((UIAlertAction)-> fileprivate func showBetaAlert(来源:String){ 让betaAlert=UIAlertController.betaProgramAlert() 让joinAction=UIAlertAction(标题:“Join”,样式:UIAle

我一直在试图找到一种方法,将多个参数传递给UIAlertAction。下面是我的代码。我想将“源”字符串传递给警报的选定操作

我遇到了这样的错误:

无法将类型“()”的值转换为预期的参数类型“((UIAlertAction)->

fileprivate func showBetaAlert(来源:String){
让betaAlert=UIAlertController.betaProgramAlert()
让joinAction=UIAlertAction(标题:“Join”,样式:UIAlertActionStyle.default,处理程序:joinSelected(警报:,源:源))
让cancelAction=UIAlertAction(标题:“取消”,样式:UIAlertActionStyle.Cancel,处理程序:cancelSelected)
betaAlert.addAction(取消操作)
betaAlert.addAction(联合动作)
当前(betaAlert,动画:真,完成:无)
}
fileprivate func joinSelected(警报:UIAlertAction,来源:字符串){
让betaAlert=UIAlertController.signUpAlert()
让cancelAction=UIAlertAction(标题:“取消”,样式:。取消,处理程序:dismissEmailAction)
让submitAction=UIAlertAction(标题:“提交”,样式:。默认值,处理程序:{[weak self]\uIn
guard let stelf=self-else{return}
让email=betaAlert.textFields![0]作为UITextField
stelf.submitAction(电子邮件:email.text!)
})
betaAlert.addAction(取消操作)
betaAlert.addAction(submitAction)
当前(betaAlert,动画:真,完成:无)
}
替换此行:

let joinAction = UIAlertAction(title: "Join", style: UIAlertActionStyle.default, handler: joinSelected(alert: <#UIAlertAction#>, source: source))
并将
joinSelected
更新为:

fileprivate func joinSelected(source: String) {

是否要在submitAction的处理程序中使用源字符串?@HAK我试图给出源字符串,但得到一个错误“调用中缺少参数'alert'的参数”在您的
joinSelected
selected方法中,您在哪里使用了
alert
source
参数?您不需要将源字符串作为参数传递到处理程序中。只需在处理程序中使用它,它将自动为块捕获。非常感谢。为我工作。
let joinAction = UIAlertAction(title: "Join", style: UIAlertActionStyle.default, handler: { [weak self] _ in
    joinSelected(source: source)
})
fileprivate func joinSelected(source: String) {