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
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.
@@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...
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
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
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 🙏
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.
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 ?
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
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 ☺️
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.
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.
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?
Sir, you are a real gem for the iOS developers. 🙏
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
@@CodeCat15 Sir pls make more videos on concurrency on iOS like Operation Queues and some more advanced concepts if possible. Thanks.🙏
Sure will do Polu
Trust me this is my first comment in any ios development video , amazing explanation
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 :)
Hey Ravi, I don't have words for how to thank you. Just ming blowing bhava!
Akshay, welcome bhava, tula kahi doubts asel tar te pan vichar ani tuja iOS group sobat pan he channel share kar 👍
yes bro I learned new concept DispatchWorkItem from this video . Thank you :-)
Am glad this was helpful 👍
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
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.
Great topic with great example and explanation! Very helpful.
Thanks Dhaval, glad the content is helpful. Do share the video with your iOS group and feel free to ask questions on the topic
Bhai ekdum mst sikhato ho, thank you🙏🙏🙏
Thanks Neeraj, koi question raha ye topic pe to please puchna zaroor aur aapne iOS group mai bhi is video ko share karna :)
clear all my doubt Thank you sir.
You are most welcome
Brilliancy ,bhai please do more and more videos ,,,,
Threading playlist link: ruclips.net/p/PLb5R4QC2DtFuSE3wpJAqvFRbal5-7sAwr
Hope it helps
@@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...
Great content sir. Grateful to access such content for free.
Very useful content.. keep rocking
Thanks a lot Sharmi
Awesome Video
Thanks for share brother
Ravi, you are Super.
Thank you Ashish :)
informative
Thank you for this video.
Superb sir 👌👌
👌👌👌
Way of explaining 🙏🙂
Very informative video Ravi....One doubt -> If we can cancel the task in GCD then what is the use of OperationQueue over it?
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
@@CodeCat15 Thank you Ravi🙂
I Think in iOS 13 there is a debounce api but thanks for the video, i learned how it works
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
Very well done
Awesome 😎
Thanks for this information. Please create a video on operation queue also
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
nice vide0
Thank you :)
Bhai ek request hai apko code font is like android bro so change it to natural iOS. Thanks for content it was worthfull.
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 🙏
@@CodeCat15 Nahi bro I also had experience with Visual studio and remember this font haha 😛. no issues.
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.
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 ?
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
Same task can achieve by published cause publishe has time & cancel property.
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 ☺️
Can we cancel api call in dispatchworkitem?
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.
Why are we calling the API on main queue?
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.
@@CodeCat15 Thank you sooo much 😊
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?
Yep, I also face the similar problem in understanding this topic. @CodeCat please answer
Let me make a video on this as comments could get a little lengthy
@@CodeCat15 sure, that'll be great.