Swift 5.5: Async Await Operations (Xcode 13, iOS 15, 2022) - iOS for Beginners

  Рет қаралды 37,399

iOS Academy

iOS Academy

3 жыл бұрын

In this video we will learn to use the new async await attributed to perform async operations in Swift. Newly available as of 2021 and Swift 5.5, this new style greatly improves upon closures, callbacks, and other concurrent patterns in Swift & iOS. We'll be working in Xcode 13 and Swift 5.5
💻 Source Code: / iosacademy
🎥 Subscribe for more: kzfaq.info?su...
😎 Like my teaching style? Check out some of my most popular courses! courses.iosacademy.io
#swift #asyncawait #wwdc2021
** Like my teaching style? Check out some of my most popular courses!
courses.iosacademy.io
Join this channel to get access to perks, code, groups, and more:
Building Instagram: courses.iosacademy.io/p/build...
Building TikTok: / @iosacademy
SwiftUI for Beginners: ios-academy.teachable.com/p/s...
Join the iOS Academy Community: iosacademy.io/
** Get Skillshare free for 2 Months and learn iOS
www.skillshare.com/r/user/afraz
** Manage all your investments from app earnings on Betterment!
bit.ly/3eBwlI9
** Grow your own KZfaq tech channel with TubeBuddy:
www.tubebuddy.com/iosacademy

Пікірлер: 76
@prithvi_acoustic
@prithvi_acoustic 2 жыл бұрын
Thank you for the great explanation
@flamboulder
@flamboulder 2 жыл бұрын
These videos are absolutely outstanding summaries thank you 🙏
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks
@difanaufalpratama8765
@difanaufalpratama8765 3 жыл бұрын
Man that so fast, it doesn't take a week and you already make tutorial for new features. Keep going bro!
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Thanks, will do!
@MrLinusunil
@MrLinusunil 2 жыл бұрын
Really good video, thanks for sharing that. It was concise and easy to understand.
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks
@DhruvilPatel
@DhruvilPatel 3 жыл бұрын
Simple and clear, thanks mate!
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Youre welcome
@davidandreasson1434
@davidandreasson1434 2 жыл бұрын
Great! simply great, thanks!!
@iOSAcademy
@iOSAcademy 2 жыл бұрын
You’re welcome
@glennadams7047
@glennadams7047 3 жыл бұрын
Nice. I think a whole series of tutorials on this is needed, with simple to complex use cases. I would buy the course if you made one :)
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Coming soon!
@glennadams7047
@glennadams7047 3 жыл бұрын
@@iOSAcademy And include all the nested network calls . like populating a table view with users, their photos, etc all separate calls, proper error handling , etc. all the pain-in-the-ass stuff. Just my $.02. regards and keep up the great work
@jineshdoshi
@jineshdoshi 2 жыл бұрын
@@iOSAcademy any ETA on this?
@cinquain0
@cinquain0 2 жыл бұрын
Beautiful video. Bravo!
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Thanks
@aidenzaw260
@aidenzaw260 Жыл бұрын
You saved my life.
@smael1989
@smael1989 3 жыл бұрын
Nice, looking forward to some practice about it
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Nice
@samha1513
@samha1513 2 жыл бұрын
async {} is now Task.init(operation: {})
@fermatslasttheorem6298
@fermatslasttheorem6298 2 жыл бұрын
Or just "Task { }" - which is the same thing. You don't have to use init and the only argument can be done with a trailing closure.
@janarthanank877
@janarthanank877 3 жыл бұрын
Easy to understand 👏🏻
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Thanks
@jerseycafe9099
@jerseycafe9099 3 жыл бұрын
good job! thanks mate!
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Youre welcome
@josejimenez7502
@josejimenez7502 3 жыл бұрын
They are making it easy.
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Yep!
@karlostj4683
@karlostj4683 2 жыл бұрын
Some imminent deprecation on the "async { ... }" call. Need to change it (going forward) to "Task { ... } "
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Yep
@franciscoarciganolasco6027
@franciscoarciganolasco6027 5 ай бұрын
can be use Task instead of async for concurrent or parallel proccesing?
@fermatslasttheorem6298
@fermatslasttheorem6298 2 жыл бұрын
Great video. I'm a senior iOS engineer but trying to catch up on some APIs I've been lazy to learn.
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Nice!
@rahulchhetri1869
@rahulchhetri1869 Жыл бұрын
same
@alley8481
@alley8481 3 жыл бұрын
Async await it's pretty cool and very simple ❤️. Thank you for u tutorial sir. Please, if is possible, make a tutorial about repository sir. 😁
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Sure I will
@junglee-bee
@junglee-bee 3 жыл бұрын
`async throws -> T` is a better option than `async -> Result` but by now I know you will say “It’s Subjective” 😝 which of course it is.
@iOSAcademy
@iOSAcademy 3 жыл бұрын
I actually love generics but a bit advanced for the general audience
@junglee-bee
@junglee-bee 3 жыл бұрын
@@iOSAcademy oh, sorry, I actually meant `async throws -> [User]` but i really like ur content. hope u hit ur 50k target soon :)
@DanielYDev
@DanielYDev 2 жыл бұрын
If a network error has occurredit is better to inform to view layer, don't you think? It may be necessary to handler the type of error or inform the user. I think...
@fermatslasttheorem6298
@fermatslasttheorem6298 2 жыл бұрын
throws or result - either is good depending on the use case.
@RahulVerma-tv6gq
@RahulVerma-tv6gq 2 жыл бұрын
But what if we are using alamofire which returns a Result type data, from which it’s not possible to return data as we can’t return anything inside cases of result, how to handle that any help would be appreciated.
@3909630
@3909630 3 жыл бұрын
yeah ima call you professor iOS now
@iOSAcademy
@iOSAcademy 3 жыл бұрын
haha thanks!
@asigivati1382
@asigivati1382 Жыл бұрын
can you or someone please tell me what is the different of the tableview variable you wrote that looks the same as lazy variable definition, but without the lazy keyword. is it behave like lazy? is this variable create only once and only when someone access to it? at 03:55
@franciscoarciganolasco6027
@franciscoarciganolasco6027 5 ай бұрын
if use Task what would happen?
@TheBooban
@TheBooban 2 жыл бұрын
The syntax is much better, it makes sense. completion handlers didn't make sense as they are part of the function parameters but when you call them, the closure is outside the params ().
@fermatslasttheorem6298
@fermatslasttheorem6298 2 жыл бұрын
Well, no they don't have to be at all. You can certainly put a closure inside the function parenthesis. What you are talking about is a trailing closure syntax, which is only if you have a closure that is the last argument of the function. You don't have to use trailing closure syntax if you don't want to.
@hajjdawood
@hajjdawood Жыл бұрын
I wish these tutorials were done in SwiftUI, much cleaner, and much faster. Instead of spending like 8 minutes setting up the project due to UIkit nonsense, just add List (user) and be done.
@coffeebydny393
@coffeebydny393 2 жыл бұрын
Thanks for the content, btw which theme in Xcode do you use?
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Midnight
@hakankumdakc9233
@hakankumdakc9233 3 жыл бұрын
how did you do that without adding import _Concurrency? I get error about couldn't found async. Also imported concurrency but couldn't found that module.
@iOSAcademy
@iOSAcademy 3 жыл бұрын
It should work in xcode 13
@TheSpiralnotizblock
@TheSpiralnotizblock 3 жыл бұрын
Do you have a video on how to use a REST API with Swift?
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Yes, just search for API on the channel
@TheSpiralnotizblock
@TheSpiralnotizblock 3 жыл бұрын
@@iOSAcademy Great!
@dhav7634
@dhav7634 2 жыл бұрын
We all know async calls do not block execution until the async operation is completed. With await being introduced are we still doing that or are we waiting on the async operation being completed?
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Waiting
@dhav7634
@dhav7634 2 жыл бұрын
@@iOSAcademy Got it. So anything that we do NOT want to wait for async call should be outside the "Task" block?
@TheBooban
@TheBooban 2 жыл бұрын
so is @escaping completion handlers obsolete now?
@iOSAcademy
@iOSAcademy 2 жыл бұрын
No. Both are still valid
@Martin-xj8rp
@Martin-xj8rp 2 жыл бұрын
@@iOSAcademy but its possible to replace the completion Blocks with it, right?
@justworkfine321
@justworkfine321 2 жыл бұрын
Is concurrency is async?
@iOSAcademy
@iOSAcademy 2 жыл бұрын
Yes
@lyphuc4362
@lyphuc4362 3 жыл бұрын
from javascript
@MrPerucan
@MrPerucan 3 жыл бұрын
Literally lol
@iOSAcademy
@iOSAcademy 3 жыл бұрын
Yep!
@glennadams7047
@glennadams7047 3 жыл бұрын
I know right ? What took so long ??? Apple is a $2T company.
@sebastianstrus6273
@sebastianstrus6273 2 жыл бұрын
Bad quality of the video. Please fix this. You hurt our eyes. Besides that, thanks for the content. It's very helpful.
@aliquewilliams3080
@aliquewilliams3080 2 жыл бұрын
You wasted almost half the video setting up the project before showing the concept. Next time, have the project already prepared.
@emmanuelpregnolato5026
@emmanuelpregnolato5026 2 жыл бұрын
I think the weak self attempt was correct. async { [weak self] in guard let _self = self else { return } let users = await fetchUsers() _self.users = users DispatchQueue.main.async { _self.tableView.reloadData() } } 🙃
@fermatslasttheorem6298
@fermatslasttheorem6298 2 жыл бұрын
As of Swift 5, you can use "let self = self "
@maqusss
@maqusss 3 жыл бұрын
setting users property in 8:54 should also happen on main thread. Does "async" in line 31 dispatch closure on current thread? that would make DispatchQueue.main.asynch from line 35 unneccesary.
@MrLinusunil
@MrLinusunil 2 жыл бұрын
AFAIK you can perfectly do that on non-main threads. Only updating the UI (like reloading the table view) needs to be on the main thread.
@maqusss
@maqusss 2 жыл бұрын
@@MrLinusunil You can if you use some kind of synchronization. Otherwise you have potential data race or inconsistent state because two threads are accessing the same property, one changing it. For example: property is read on main thread in table view data source method numberOfRows, then propeerty is changed on non-main thread before cellForRowAt call, then you have crash "index out of range".
Khóa ly biệt
01:00
Đào Nguyễn Ánh - Hữu Hưng
Рет қаралды 21 МЛН
THEY made a RAINBOW M&M 🤩😳 LeoNata family #shorts
00:49
LeoNata Family
Рет қаралды 5 МЛН
OMG🤪 #tiktok #shorts #potapova_blog
00:50
Potapova_blog
Рет қаралды 17 МЛН
Swift: Actors Introduction (2023, Xcode 13) - iOS
8:54
iOS Academy
Рет қаралды 38 М.
How to use async / await keywords in Swift  | Swift Concurrency #3
20:40
Swiftful Thinking
Рет қаралды 24 М.
Swift: Keychain Introduction (2022) - iOS
17:43
iOS Academy
Рет қаралды 26 М.
3 MISTAKES to avoid when using Async / Await in Swift 😌
4:41
Vincent Pradeilles
Рет қаралды 10 М.
Async Sequence in Swift (2022)
11:11
iOS Academy
Рет қаралды 9 М.
Swift API Calls for Beginners (Networking) - Async Await & JSON
25:35
Prefetching with TableViews (2022) - iOS
16:35
iOS Academy
Рет қаралды 18 М.
Khóa ly biệt
01:00
Đào Nguyễn Ánh - Hữu Hưng
Рет қаралды 21 МЛН