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

Поделиться
HTML-код
  • Опубликовано: 12 янв 2025

Комментарии • 47

  • @parthbarot-nc8mr
    @parthbarot-nc8mr Год назад +1

    Very detailed explanation...!! Thanks for sharing...

  • @gratifirnr9886
    @gratifirnr9886 Месяц назад +1

    Super Awesome Explaination Yogesh Sir.. 👌🙌👏

  • @vishalbavaliya5788
    @vishalbavaliya5788 Год назад +1

    Super 👍

  • @SauravSagar-rj8mp
    @SauravSagar-rj8mp 10 месяцев назад +1

    Thankyou Yogesh bhai awesome hai ye..

  • @AnkitaJaiswal-v9f
    @AnkitaJaiswal-v9f 6 месяцев назад +1

    Very nicely explained. Thankyou :)

  • @Sanilsysitco
    @Sanilsysitco Год назад +1

    Super...and Thanksssss....

  • @navikaushal1795
    @navikaushal1795 Год назад +1

    Thank you so much Yogesh sir I really want to understand the concept of async await. Thanks again

  • @ImranJutt-u5v
    @ImranJutt-u5v Год назад +1

    Super❤❤

  • @chetanzala975
    @chetanzala975 Год назад +1

    Thank you such video Yogesh sir :)

  • @khanshahbaz3004
    @khanshahbaz3004 Год назад +2

    Thanks bro, I appreciate your way of explaining and the knowledge you share.

    • @YogeshPateliOS
      @YogeshPateliOS  Год назад +1

      Glad you like it. Please like, subscriber and share with you friends :)

  • @developertesting130
    @developertesting130 Год назад +1

    that is also good one,Thanks

  • @ImranJutt-u5v
    @ImranJutt-u5v Год назад +1

    ❤❤

  • @bhavesh.gamara5851
    @bhavesh.gamara5851 Год назад +1

    જય દ્વારીકાધીશ યોગેશ ભાઈ

    • @YogeshPateliOS
      @YogeshPateliOS  Год назад

      જય દ્વારીકાધીશ ભાઈ

  • @shubhamkshatriya2609
    @shubhamkshatriya2609 Год назад +1

    Nice explanation. Please start swiftui tutorials.

  • @ImranJutt-u5v
    @ImranJutt-u5v Год назад +1

  • @vishalgohil2363
    @vishalgohil2363 Год назад +1

    Good explanation!
    keep it up 🎉

  • @Mohsinqureshi6491
    @Mohsinqureshi6491 8 месяцев назад +1

    Hello Yosgesh, can you please make a video on more than 2 API calls on any screen using
    async/await

  • @AmitBiswastunebox
    @AmitBiswastunebox 5 месяцев назад +1

    Bro could you please create a video about advanced debugging techniques.

  • @ammarulhaq6517
    @ammarulhaq6517 Год назад +1

    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  Год назад

      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

  • @Crazyness.c
    @Crazyness.c Год назад +1

    Try to save api response in core data and realme db or firebase db .

  • @ShakeelAhmed-jb6nu
    @ShakeelAhmed-jb6nu Год назад

    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.

  • @Yourstruly_suna
    @Yourstruly_suna Год назад

    Hello yogesh..do you give online classes to learn iOS development?i want to learn please reply

  • @Sanilsysitco
    @Sanilsysitco Год назад +1

    Sir..Can we have a session on video call , video streaming etc?

  • @bhavinkansara3393
    @bhavinkansara3393 Год назад +1

    Could you make a video GraphQL ?

  • @ammarulhaq6517
    @ammarulhaq6517 Год назад +1

    Hi Sir,
    Does @MainActor blocks main thread ?

    • @YogeshPateliOS
      @YogeshPateliOS  Год назад

      Hey, No it is not block the main thread. It call your ui or logic in main thread 👍🏻

  • @AmitGupta-xc9gq
    @AmitGupta-xc9gq Год назад

    How can we send the multiple json object in single post request?

  • @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.

  • @sagarsharma3414
    @sagarsharma3414 Год назад +1

    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.

  • @umarparacha653
    @umarparacha653 Год назад +1

    multiply images wala bhee
    kr daaa

  • @pradeepkas10
    @pradeepkas10 Год назад +1

    Hello Yogesh
    Thank you for all content.
    When we can see RXSwift with MVVM videos ?? Please plan this as well if possible, thank you

  • @hunghuynhmanh2397
    @hunghuynhmanh2397 Год назад +1

    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:

  • @creations_saumya234
    @creations_saumya234 6 месяцев назад +1

    Very detailed explanation...!! Thanks for sharing...

  • @ImranJutt-u5v
    @ImranJutt-u5v Год назад +1

    ❤❤