func method1() async {         //Do Something.     }         func method2() async {         //Do Something.     }
        await method1()         await method2()  
         Task.init {             await method1()             await method2()         }  
    //Declaration    func method1(_ completion: @escaping (String) -> Void) {        //Do Something.       completion(“value”)    }        func method2(_ name: String) {       //Do Something.    }        //Execution    method1 { name in        self.method2(name)    }    

Now with the help of async/await, we can directly get the value from the first method, await for that value, and then continue the execution.

       //Declaration     func method1() async -> String {         //Do Something.         return “Value”     }         func method2() async {         let name = await method1()         print(name)     }         //Execution     await method2()

 

Conclusion

In this blog, we saw, what the async/await feature is, why it should be used, and what we used to do before having it.

Async/await is good for our processing chips. Here every asynchronous method separates its thread. So, the main thread does not get so much pressure. Moreover, it saves time for users that was otherwise spent waiting for any method to complete its execution.