Cancel task in Grand Central Dispatch GCD with DispatchWorkItem in Swift Hindi tutorial

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

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

  • @polu9132
    @polu9132 3 года назад +8

    Sir, you are a real gem for the iOS developers. 🙏

    • @CodeCat15
      @CodeCat15  3 года назад

      Thank you 😊 I am glad the video was helpful. Plz do ask questions on this topic and do share the video with your iOS group

    • @polu9132
      @polu9132 3 года назад

      @@CodeCat15 Sir pls make more videos on concurrency on iOS like Operation Queues and some more advanced concepts if possible. Thanks.🙏

    • @CodeCat15
      @CodeCat15  3 года назад +1

      Sure will do Polu

  • @GovindSingh-vf7ff
    @GovindSingh-vf7ff 3 года назад +1

    Trust me this is my first comment in any ios development video , amazing explanation

    • @CodeCat15
      @CodeCat15  3 года назад

      Welcome to the channel Goving and thank you for taking time and commenting on the video, I am glad the contents of this channel are helpful :)

  • @akshaygajarlawar8878
    @akshaygajarlawar8878 3 года назад +1

    Hey Ravi, I don't have words for how to thank you. Just ming blowing bhava!

    • @CodeCat15
      @CodeCat15  3 года назад

      Akshay, welcome bhava, tula kahi doubts asel tar te pan vichar ani tuja iOS group sobat pan he channel share kar 👍

  • @icodingschool9018
    @icodingschool9018 3 года назад +1

    yes bro I learned new concept DispatchWorkItem from this video . Thank you :-)

    • @CodeCat15
      @CodeCat15  3 года назад

      Am glad this was helpful 👍

  • @darshantelang1535
    @darshantelang1535 3 года назад +1

    Excellent explanation. These videos are fulfilling the gap for me of not being trained professionally as trainee and using random techniques, internet solutions to solve problems in task deadline and later sit and regret for writing bad code and waste further more time to clean the previous code. I am feeling a technical detox by watching several of these videos on daily basis. Kudos to the creator. #CheersToCodeCat15

    • @CodeCat15
      @CodeCat15  3 года назад +2

      I like the term technical detox, funny thing is implementing clean code takes a little time but has long term benefits specially with regards to change requests, we surely don't want our codebase to be like a card house, you remove or replace one card and the entire house collapses.

  • @dhavalnena7386
    @dhavalnena7386 2 года назад +1

    Great topic with great example and explanation! Very helpful.

    • @CodeCat15
      @CodeCat15  2 года назад

      Thanks Dhaval, glad the content is helpful. Do share the video with your iOS group and feel free to ask questions on the topic

  • @NeerajKumar-tx1qo
    @NeerajKumar-tx1qo 3 года назад +1

    Bhai ekdum mst sikhato ho, thank you🙏🙏🙏

    • @CodeCat15
      @CodeCat15  3 года назад

      Thanks Neeraj, koi question raha ye topic pe to please puchna zaroor aur aapne iOS group mai bhi is video ko share karna :)

  • @hardipgajera2316
    @hardipgajera2316 3 года назад +1

    clear all my doubt Thank you sir.

    • @CodeCat15
      @CodeCat15  3 года назад

      You are most welcome

  • @indianbachelorkitchen6410
    @indianbachelorkitchen6410 2 года назад +1

    Brilliancy ,bhai please do more and more videos ,,,,

    • @CodeCat15
      @CodeCat15  2 года назад

      Threading playlist link: ruclips.net/p/PLb5R4QC2DtFuSE3wpJAqvFRbal5-7sAwr
      Hope it helps

    • @indianbachelorkitchen6410
      @indianbachelorkitchen6410 2 года назад

      @@CodeCat15 ya bhai making notes out of all videos from the playlist... Thanks bahi really, har baar interview ma a topic pareshaan karta tha ....now it will not...

  • @abhijnanmaji2682
    @abhijnanmaji2682 2 года назад

    Great content sir. Grateful to access such content for free.

  • @sharmiv1060
    @sharmiv1060 3 года назад +1

    Very useful content.. keep rocking

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

    Awesome Video
    Thanks for share brother

  • @ashishjaiswal3941
    @ashishjaiswal3941 3 года назад

    Ravi, you are Super.

  • @fitdevelopertv5148
    @fitdevelopertv5148 3 года назад +1

    informative

  • @Mandhata9
    @Mandhata9 2 года назад

    Thank you for this video.

  • @Cartoon_FunStory
    @Cartoon_FunStory 3 года назад

    Superb sir 👌👌

  • @MrVivekkumarpal
    @MrVivekkumarpal 2 года назад

    👌👌👌

  • @akashrevanna5327
    @akashrevanna5327 3 года назад

    Way of explaining 🙏🙂

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

    Very informative video Ravi....One doubt -> If we can cancel the task in GCD then what is the use of OperationQueue over it?

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

      i made a video about this, please check it out and let me know if you have any queries
      video link: ruclips.net/video/JuFAW7y8lp0/видео.html

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

      @@CodeCat15 Thank you Ravi🙂

  • @unseenSky
    @unseenSky 3 года назад +1

    I Think in iOS 13 there is a debounce api but thanks for the video, i learned how it works

    • @CodeCat15
      @CodeCat15  3 года назад +1

      Indeed Somendra, using the combine framework we surely can implement debounce, but its from ios 13 onwards wish there was backward compatibility but its alright we have DispatchWorkItem to the rescue. Please feel free to ask questions on the topic and do share the channel with your iOS group

  • @aafaqahmed2265
    @aafaqahmed2265 3 года назад

    Very well done

  • @IleshPanchalOnly
    @IleshPanchalOnly 3 года назад

    Awesome 😎

  • @PrashantKumar-fg4tg
    @PrashantKumar-fg4tg 3 года назад

    Thanks for this information. Please create a video on operation queue also

    • @CodeCat15
      @CodeCat15  3 года назад +1

      Hello Prashant, welcome to the channel I am glad this video was helpful. Please do feel free to ask questions on this topic and yes a video on operation queue and other threading concepts are on their way very soon

  • @ranganathc3170
    @ranganathc3170 3 года назад +1

    nice vide0

  • @suryakantsharma6761
    @suryakantsharma6761 3 года назад +1

    Bhai ek request hai apko code font is like android bro so change it to natural iOS. Thanks for content it was worthfull.

    • @CodeCat15
      @CodeCat15  3 года назад

      Mai initially asp.net developer tha aur hum visual studio use karte the jiska default font hai consolas aur abhi 10 saalo se vahi font ki adat ho chuki hai koi bhi editor ho meri font family fixed hai, maine try kiya tha xcode ka default font but then jama nahi mujhe sorry agar font ka vajaha se koi dikkat aai aapko 🙏

    • @suryakantsharma6761
      @suryakantsharma6761 3 года назад

      @@CodeCat15 Nahi bro I also had experience with Visual studio and remember this font haha 😛. no issues.

  • @vashusaini021
    @vashusaini021 5 месяцев назад

    Brother
    I did not get this can someone please explain me.
    How DispatchWorkItem is cancelling the task? isCancellled bool which we checking here in for loop this bool variable is used for cancelling this for loop task (even cancelling by developer using break) not workitem.

  • @vincentjoyhere
    @vincentjoyhere 3 года назад +1

    One difference between dispatch work item and operation queue is -
    Dispatch work item can execute and cancel only one operation, whereas an operation queue can execute multiple operations concurrently and cancel together all if needed using the cancelAllOperations() method.
    Is that correct ?

    • @CodeCat15
      @CodeCat15  3 года назад

      Apple recommends that you should always use the highest level of abstraction, which means we should be using operation queue and not GCD which is a low level api, but due to convince many devs including me go for gcd directly.
      Having said that, operation queue holds its place coz it can handle dependencies and you can pause and yes cancel all operations, operation queue does things more object oriented way than GCD and we have more control over what we are trying to do with operation queue than GCD

  • @Sameerkhan-pu7kn
    @Sameerkhan-pu7kn 3 года назад

    Same task can achieve by published cause publishe has time & cancel property.

    • @CodeCat15
      @CodeCat15  3 года назад +1

      That’s more swiftui and am yet to explore that world of swiftui but it will be very interesting to see that and how it works or how it’s different from dispatchWorkItem I’ll make a note of this Sameer thanks for sharing ☺️

  • @ajaykumar-kq2wf
    @ajaykumar-kq2wf 2 года назад +1

    Can we cancel api call in dispatchworkitem?

    • @CodeCat15
      @CodeCat15  2 года назад

      You can cancel the work item itself which will ultimately cancel whatever workItem it was intent to do
      What this means is the API call which is already done to the server that call may happen and say before you receive the response if you cancel the workItem then in that case the response will be ignored.
      In theory I believe this is what should happen but you can try this out and confirm if this works as per your given usecase.

  • @keertikagupta
    @keertikagupta 3 года назад +1

    Why are we calling the API on main queue?

    • @CodeCat15
      @CodeCat15  3 года назад

      Hey Keertika, url session internally calls the api on a background thread on its own so we don’t really have to specify or use a dispatch queue. If you watch the serial api call video there you can see this behavior
      Video link: ruclips.net/video/II7bJmC64IY/видео.html
      Let me know if that answers your question and if not plz feel free to ask more.

    • @keertikagupta
      @keertikagupta 3 года назад +1

      @@CodeCat15 Thank you sooo much 😊

  • @desijugaad908
    @desijugaad908 3 года назад +2

    hello, I really enjoy your video.. so informative.. and to the point. hats off to you.
    It would be really helpful if you create a video on the topic of the different combination of sync and async block using different dispatch queues(serial, concurrent, main &global). I really got confused of the flow in some of the questions like below,
    func testx(){
    defer {
    print("--testx--")
    }
    DispatchQueue.main.async {
    print("testx")
    }
    print("--testx")
    }
    func testy(){
    defer {
    print("--testy--")
    }
    DispatchQueue.main.async {
    print("testy")
    }
    print("--testy")
    }
    func test(){
    print("01")
    testx()
    print("02")
    testy()
    print("03")
    }
    test()
    this will print:
    01
    --testx
    --testx--
    02
    --testy
    --testy--
    03
    testx
    testy
    here the dispatch asyn block executed at last why that so?

    • @ankurgupta2502
      @ankurgupta2502 3 года назад

      Yep, I also face the similar problem in understanding this topic. @CodeCat please answer

    • @CodeCat15
      @CodeCat15  3 года назад +1

      Let me make a video on this as comments could get a little lengthy

    • @desijugaad908
      @desijugaad908 3 года назад

      ​@@CodeCat15 sure, that'll be great.