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

Sdílet
Vložit
  • čas přidán 26. 08. 2024

Komentáře • 60

  • @polu9132
    @polu9132 Před 3 lety +8

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

    • @CodeCat15
      @CodeCat15  Před 3 lety

      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 Před 3 lety

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

    • @CodeCat15
      @CodeCat15  Před 3 lety +1

      Sure will do Polu

  • @GovindSingh-vf7ff
    @GovindSingh-vf7ff Před 3 lety +1

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

    • @CodeCat15
      @CodeCat15  Před 3 lety

      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 :)

  • @darshantelang1535
    @darshantelang1535 Před 3 lety +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  Před 3 lety +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.

  • @akshaygajarlawar8878
    @akshaygajarlawar8878 Před 3 lety +1

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

    • @CodeCat15
      @CodeCat15  Před 3 lety

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

  • @icodingschool9018
    @icodingschool9018 Před 3 lety +1

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

    • @CodeCat15
      @CodeCat15  Před 3 lety

      Am glad this was helpful 👍

  • @dhavalnena7386
    @dhavalnena7386 Před 2 lety +1

    Great topic with great example and explanation! Very helpful.

    • @CodeCat15
      @CodeCat15  Před 2 lety

      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 Před 3 lety +1

    Bhai ekdum mst sikhato ho, thank you🙏🙏🙏

    • @CodeCat15
      @CodeCat15  Před 3 lety

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

  • @vyankateshshivnikar7932
    @vyankateshshivnikar7932 Před rokem +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  Před rokem +1

      i made a video about this, please check it out and let me know if you have any queries
      video link: czcams.com/video/JuFAW7y8lp0/video.html

    • @vyankateshshivnikar7932
      @vyankateshshivnikar7932 Před rokem

      @@CodeCat15 Thank you Ravi🙂

  • @abhijnanmaji2682
    @abhijnanmaji2682 Před 2 lety

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

  • @hardipgajera2316
    @hardipgajera2316 Před 3 lety +1

    clear all my doubt Thank you sir.

  • @indianbachelorkitchen6410

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

    • @CodeCat15
      @CodeCat15  Před 2 lety

      Threading playlist link: czcams.com/play/PLb5R4QC2DtFuSE3wpJAqvFRbal5-7sAwr.html
      Hope it helps

    • @indianbachelorkitchen6410
      @indianbachelorkitchen6410 Před 2 lety

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

  • @sharmiv1060
    @sharmiv1060 Před 3 lety +1

    Very useful content.. keep rocking

  • @unseenSky
    @unseenSky Před 3 lety +1

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

    • @CodeCat15
      @CodeCat15  Před 3 lety +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

  • @pratapapptunix3512
    @pratapapptunix3512 Před rokem

    Awesome Video
    Thanks for share brother

  • @MrVivekkumarpal
    @MrVivekkumarpal Před 2 lety

    👌👌👌

  • @ashishjaiswal3941
    @ashishjaiswal3941 Před 3 lety

    Ravi, you are Super.

  • @suryakantsharma6761
    @suryakantsharma6761 Před 3 lety +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  Před 3 lety

      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 Před 3 lety

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

  • @Mandhata9
    @Mandhata9 Před 2 lety

    Thank you for this video.

  • @fitdevelopertv5148
    @fitdevelopertv5148 Před 3 lety +1

    informative

  • @akashrevanna5327
    @akashrevanna5327 Před 3 lety

    Way of explaining 🙏🙂

  • @Cartoon_FunStory
    @Cartoon_FunStory Před 3 lety

    Superb sir 👌👌

  • @PrashantKumar-fg4tg
    @PrashantKumar-fg4tg Před 3 lety

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

    • @CodeCat15
      @CodeCat15  Před 3 lety +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

  • @aafaqahmed2265
    @aafaqahmed2265 Před 3 lety

    Very well done

  • @vashusaini021
    @vashusaini021 Před 5 měsíci

    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.

  • @IleshPanchalOnly
    @IleshPanchalOnly Před 3 lety

    Awesome 😎

  • @ranganathc3170
    @ranganathc3170 Před 3 lety +1

    nice vide0

  • @vincentjoyhere
    @vincentjoyhere Před 3 lety +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  Před 3 lety

      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

  • @ajaykumar-kq2wf
    @ajaykumar-kq2wf Před 2 lety +1

    Can we cancel api call in dispatchworkitem?

    • @CodeCat15
      @CodeCat15  Před 2 lety

      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.

  • @Sameerkhan-pu7kn
    @Sameerkhan-pu7kn Před 3 lety

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

    • @CodeCat15
      @CodeCat15  Před 3 lety +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 ☺️

  • @keertikagupta
    @keertikagupta Před 3 lety +1

    Why are we calling the API on main queue?

    • @CodeCat15
      @CodeCat15  Před 3 lety

      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: czcams.com/video/II7bJmC64IY/video.html
      Let me know if that answers your question and if not plz feel free to ask more.

    • @keertikagupta
      @keertikagupta Před 3 lety +1

      @@CodeCat15 Thank you sooo much 😊

  • @desijugaad908
    @desijugaad908 Před 3 lety +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 Před 3 lety

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

    • @CodeCat15
      @CodeCat15  Před 3 lety +1

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

    • @desijugaad908
      @desijugaad908 Před 3 lety

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