Use Async Await with MVVM and URLSession (JSON API Calls ) | Swift Concurrency Hindi 2024 | Xcode 15

  Рет қаралды 8,215

Yogesh Patel

Yogesh Patel

Күн бұрын

In this video, you will learn about Swift concurrency feature, Async Await, MainActor, Task and explore how it can be seamlessly integrated with the MVVM architecture and URLSession. Join us as we unlock the full potential of Swift Concurrency and learn how to write efficient, responsive, and scalable code. Stay ahead of the curve and elevate your Swift development skills in 2024!
📕 Github Project:
Download Project - github.com/Yog...
📹 KZbin Videos:
MVVM With API: • Part 1 - MVVM (Model V...
📱 My Applications:
G1 Driving Test - Ontario 2023
apps.apple.com...
My Music - Play & Share
apps.apple.com...
BMI Weight Loss Calculator
apps.apple.com...
🙋‍♂️ Say Hi on Social Media:
Linkedin: / yogeshpatelios
Instagram: / codewithyogesh
By Me A Coffee: www.buymeacoff...
If you enjoyed this project and found it useful, please share and recommend it so others can find it 💚💚💚💚💚💚 !!!!
/ yogeshpatelios - Please Like, Subscribe and share if it found useful for you 🤟
Enjoy!!! 😀

Пікірлер: 45
@creations_saumya234
@creations_saumya234 4 ай бұрын
Very detailed explanation...!! Thanks for sharing...
@YogeshPateliOS
@YogeshPateliOS 4 ай бұрын
Glad it was helpful!
@ImranJutt-u5v
@ImranJutt-u5v Жыл бұрын
❤❤
@vishalbavaliya5788
@vishalbavaliya5788 Жыл бұрын
Super 👍
@SauravSagar-rj8mp
@SauravSagar-rj8mp 7 ай бұрын
Thankyou Yogesh bhai awesome hai ye..
@Sanilsysitco
@Sanilsysitco Жыл бұрын
Super...and Thanksssss....
@ImranJutt-u5v
@ImranJutt-u5v Жыл бұрын
@AnkitaJaiswal-v9f
@AnkitaJaiswal-v9f 3 ай бұрын
Very nicely explained. Thankyou :)
@ImranJutt-u5v
@ImranJutt-u5v Жыл бұрын
Super❤❤
@YogeshPateliOS
@YogeshPateliOS Жыл бұрын
Thanks 🔥
@navikaushal1795
@navikaushal1795 Жыл бұрын
Thank you so much Yogesh sir I really want to understand the concept of async await. Thanks again
@YogeshPateliOS
@YogeshPateliOS Жыл бұрын
You're most welcome brother :-)
@developertesting130
@developertesting130 Жыл бұрын
that is also good one,Thanks
@YogeshPateliOS
@YogeshPateliOS Жыл бұрын
Glad you like it!
@chetanzala975
@chetanzala975 Жыл бұрын
Thank you such video Yogesh sir :)
@YogeshPateliOS
@YogeshPateliOS Жыл бұрын
Most welcome 😊
@khanshahbaz3004
@khanshahbaz3004 Жыл бұрын
Thanks bro, I appreciate your way of explaining and the knowledge you share.
@YogeshPateliOS
@YogeshPateliOS Жыл бұрын
Glad you like it. Please like, subscriber and share with you friends :)
@bhavesh.gamara5851
@bhavesh.gamara5851 Жыл бұрын
જય દ્વારીકાધીશ યોગેશ ભાઈ
@YogeshPateliOS
@YogeshPateliOS Жыл бұрын
જય દ્વારીકાધીશ ભાઈ
@shubhamkshatriya2609
@shubhamkshatriya2609 Жыл бұрын
Nice explanation. Please start swiftui tutorials.
@AmitBiswastunebox
@AmitBiswastunebox 2 ай бұрын
Bro could you please create a video about advanced debugging techniques.
@vishalgohil2363
@vishalgohil2363 Жыл бұрын
Good explanation! keep it up 🎉
@YogeshPateliOS
@YogeshPateliOS Жыл бұрын
Thank you! 😃
@Mohsinqureshi6491
@Mohsinqureshi6491 5 ай бұрын
Hello Yosgesh, can you please make a video on more than 2 API calls on any screen using async/await
@ammarulhaq6517
@ammarulhaq6517 11 ай бұрын
Hi Sir, In this video, View Controller is tightly coupled to viewModel. So basically view controller is depending on viewModel. How can me make it loosely coupled ?
@YogeshPateliOS
@YogeshPateliOS 11 ай бұрын
Hey, please check my mvvm video on product api there i use protocol so basically you are not depending on viewmodel. We depend on abstract layer protocol. This video is mainly based on Async Await 😄 Thank You
@ShakeelAhmed-jb6nu
@ShakeelAhmed-jb6nu 9 ай бұрын
understanding achi ha but Yogesh hamara do cash ab har Controller me linkhana pary ga so i think achi aproach ni ha ViewController level pay it should be in wrapper please reply.
@bhavinkansara3393
@bhavinkansara3393 Жыл бұрын
Could you make a video GraphQL ?
@Yourstruly_suna
@Yourstruly_suna Жыл бұрын
Hello yogesh..do you give online classes to learn iOS development?i want to learn please reply
@Crazyness.c
@Crazyness.c Жыл бұрын
Try to save api response in core data and realme db or firebase db .
@Sanilsysitco
@Sanilsysitco Жыл бұрын
Sir..Can we have a session on video call , video streaming etc?
@leonardodavinci2856
@leonardodavinci2856 Жыл бұрын
Question: When I run the request function in which thread does it run ? Does it run on main thread or uses a qos like .utility. Because when the we get response from data and setting it directly it is giving the error that it needs to be done in the main thread. So just wanted to know which thread it is used by default by the async functions. And also in non async function what is the thread. So like if i didnt had the async function and then I was setting the data in the fetchUsers I think it wont give me any issue as per my experience. PS: Nice videos. Wanted to learn concurrency. Very informative.
@AmitGupta-xc9gq
@AmitGupta-xc9gq Жыл бұрын
How can we send the multiple json object in single post request?
@ammarulhaq6517
@ammarulhaq6517 11 ай бұрын
Hi Sir, Does @MainActor blocks main thread ?
@YogeshPateliOS
@YogeshPateliOS 11 ай бұрын
Hey, No it is not block the main thread. It call your ui or logic in main thread 👍🏻
@umarparacha653
@umarparacha653 Жыл бұрын
multiply images wala bhee kr daaa
@sagarsharma3414
@sagarsharma3414 Жыл бұрын
How we can pass params,headers and api type(get,post) using this method ?
@YogeshPateliOS
@YogeshPateliOS Жыл бұрын
In this video we create url and we pass in datatask method. If you want to pass header, type etc first you need to create a urlrequest and then pass it to dataTask(for: urlRequest) ok sagar 🤝 In request you can add method type, body and header.
@pradeepkas10
@pradeepkas10 Жыл бұрын
Hello Yogesh Thank you for all content. When we can see RXSwift with MVVM videos ?? Please plan this as well if possible, thank you
@YogeshPateliOS
@YogeshPateliOS Жыл бұрын
Will upload soon bro 🤝
@ShakeelAhmed-jb6nu
@ShakeelAhmed-jb6nu 9 ай бұрын
RX Swift is totally rubish
@hunghuynhmanh2397
@hunghuynhmanh2397 Жыл бұрын
import Foundation import KRProgressHUD import SwiftyJSON import Alamofire class ApiCall: NSObject, RequestInterceptor { static let share: ApiCall = { return ApiCall() }() let retryLimit = 3 func request(_ apiRouter: URLRequestConvertible, hasProgress: Bool, isShowError: Bool = true, completion: @escaping (JsonResult) -> Void) { if !NetworkServices.isNetworkAvailable() { if isShowError { Toast(text: "Unable to connect to the server, please check your network connection and try again").show() } completion(.failure(.serverTrustEvaluationFailed(reason: .noCertificatesFound), nil)) return } if hasProgress { KRProgressHUD.show() } AF.request(apiRouter, interceptor: self).validate().responseData { response in if hasProgress { KRProgressHUD.dismiss() } switch response.result { case .success(let data): do { let json = try JSON(data: data) print("- result \(apiRouter.urlRequest?.url?.absoluteString ?? ""): \(json)") completion(.success(json)) } catch { completion(.success(JSON.null)) } case .failure(let error): print(error.localizedDescription) completion(.failure(error, response.response?.statusCode)) break } } } func requestFormData(_ router: URLRequestConvertible, image: ImageModel?, hasProgress: Bool, completion: @escaping (JsonResult) -> Void) { if !NetworkServices.isNetworkAvailable() { Toast(text: "Unable to connect to the server, please check your network connection and try again").show() completion(.failure(.serverTrustEvaluationFailed(reason: .noCertificatesFound), nil)) return } if hasProgress { KRProgressHUD.show() } var params: [String: Any]? var url: String? var headers: HTTPHeaders? var method: HTTPMethod? if let rt = router as? APIRouter { params = rt.parameters url = Api.me.baseUrl + rt.path headers = rt.headers method = rt.method } guard let pr = params, let u = url, var h = headers, let m = method else { return } h["Content-type"] = "multipart/form-data" h["Accept"] = "*/*" print("requestFormData") print("url: \(u)") print("params: \(pr)") print("method: \(m)") print("headers: \(h)") let block = { (multipart: MultipartFormData) in URLEncoding.default.queryParameters(pr).forEach { (key, value) in if let data = value.data(using: .utf8) { multipart.append(data, withName: key) } } if let image = image, let im = ImagePickerManager.loadImage(fileName: image.id), let data = im.resizeImageToData(CGSize(width: 1024, height: 1024)) { multipart.append(data, withName: "image", fileName: "\(Date.init().timeIntervalSince1970).png", mimeType: "image/png") } } AF.upload(multipartFormData: block, to: u, method: m, headers: h) .responseData { response in if hasProgress { KRProgressHUD.dismiss() } switch response.result { case .success(let data): do { let json = try JSON(data: data) print("- result: \(json)") completion(.success(json)) } catch { completion(.success(JSON.null)) } case .failure(let error): print(error.localizedDescription) completion(.failure(error, response.response?.statusCode)) break } } } } extension URLEncoding { public func queryParameters(_ parameters: [String: Any]) -> [(String, String)] { var components: [(String, String)] = [] for key in parameters.keys.sorted(by:
@parthbarot-nc8mr
@parthbarot-nc8mr 11 ай бұрын
Very detailed explanation...!! Thanks for sharing...
@ImranJutt-u5v
@ImranJutt-u5v Жыл бұрын
❤❤
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 82 МЛН
Сюрприз для Златы на день рождения
00:10
Victoria Portfolio
Рет қаралды 2,3 МЛН
Хасанның өзі эфирге шықты! “Қылмыстық топқа қатысым жоқ” дейді. Талғарда не болды? Халық сене ме?
09:25
Демократиялы Қазақстан / Демократический Казахстан
Рет қаралды 339 М.
Friends make memories together part 2  | Trà Đặng #short #bestfriend #bff #tiktok
00:18
Swift API Calls for Beginners (Networking) - Async Await & JSON
25:35
map, compactMap and flatMap in Swift 5 Hindi 2023 | SWIFT INTERVIEW
24:04
MVVM with SwiftUI and Combine | iOS | Demo Application
32:43
AppCoders
Рет қаралды 3,5 М.
MVVM Architecture in iOS (Swift)
34:25
Venu Gopal Tewari
Рет қаралды 6 М.
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 82 МЛН