I\'m learning Swift lang, but I cannot pass optional callback argument into function:
func dismiss(completion: () -> Void) {
if (completion) {
ret
It's better to add = nil
in the callback declaration, to avoid passing nil while calling it:
func dismiss(completion: (() -> Void)? = nil) {
if (completion) {
return self.dismissViewControllerAnimated(true, completion: completion)
}
self.dismissModalViewControllerAnimated(true) }
And you can call your function like this : dismiss()