티스토리 뷰
func startGADInterstitial(completion: (() -> Void)!){
}
// completion option 1
startGADInterstitial(completion: nil
})
// completion option 2
startGADInterstitial(completion: { () -> Void in
})
======================================
======================================
typealias CompletionHandler = (success:Bool) -> Void
func downloadFileFromURL(url: NSURL,completionHandler: CompletionHandler) {
// download code.
let flag = true // true if download succeed,false otherwise
completionHandler(success: flag)
}
// How to use it.
downloadFileFromURL(NSURL(string: "url_str")!, { (success) -> Void in
// When download completes,control flow goes here.
if success {
// download success
} else {
// download fail
}
})
'Functions' 카테고리의 다른 글
Timer Function (0) | 2016.10.16 |
---|