Import Uikit@uiapplicationmainclassAppdelegate:uiresponder, uiapplicationdelegate {var window:uiwindow?func Application (application:uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject:anyobject]< /c3>?) -Bool {Self.window=UIWindow (Frame:UIScreen.mainScreen (). Bounds)//Override point for customization after application launch.self.window!. BackgroundColor =Uicolor.whitecolor () Self.window!. Rootviewcontroller =Rootviewcontroller () Self.window!. makekeyandvisible ()return true }}
Import UIKitclassRootviewcontroller:uiviewcontroller {Overridefunc viewdidload () {super.viewdidload ()//Call the ProcessData functionProcessData {()-IntinchPrint ("Callback") return - } } /** * Closures return integral type data*/func ProcessData (printsomething: ()-Int) {Print ("Perform Actions") //Execute closure CallbackLet num =printsomething () print ("closed Packet return value num:\ (num)") }}
Simple use of SWIFT closures two