The error itself means that you are trying to use a variable to initialize itself.
In your case it's just a missing bracket, causing code to be misaligned. This is how your code looks like:
var okAction = UIAlertAction(title: pagetitle, style: .Default){ action in
self.presentingViewController!.dismissViewControllerAnimated(false, completion: { ()->Void in
self.unitDetailProtocolVar!.closeUnitDetail()
})
alertActionButtons.append(okAction)
self.alert = self.controllerUtil.customAlert(pagetitle, buttons: alertActionButtons, alertMessage: alertMessage)
}
and you can see that okAction is used in this line:
alertActionButtons.append(okAction)
The missing bracket in your code is in the closure passed to the UIAlertAction:
var okAction = UIAlertAction(title: pagetitle, style: .Default){ action in
self.presentingViewController!.dismissViewControllerAnimated(false, completion: { ()->Void in
self.unitDetailProtocolVar!.closeUnitDetail()
})
} // <-- this is missing
alertActionButtons.append(okAction)
self.alert = self.controllerUtil.customAlert(pagetitle, buttons: alertActionButtons, alertMessage: alertMessage)