Multiple API calls with Dispatch Group in Swift iOS Hindi tutorial

preview_player
Показать описание
Dispatch group can be used in scenarios where we need to do multiple tasks at the same time like you may need to call multiple APIs at the same time. In this swift tutorial, we will understand what are dispatch group and how to use them with simple and easy to understand examples.

One of the key things we have to keep a note of is we have to maintain the sequence of dispatch group enter and dispatch group leave function because failing to do so will not call the dispatch group notify function which is used to call the main thread to return the result of execution.

We will also talk about the dispatch group wait function, I personally have not used it because I am yet to run into a situation where it becomes mandatory for me to use that function however, there’s a catch for using the wait function of the dispatch group which is explained in the video

DispatchGroup also has certain limitations which are discussed at the end of the video, I would not call them limitations but they are just some good to know details.

Given are certain video links that were discussed during the video

Given are the chapters covered in today's tutorial
0:00 Introduction
0:50 Project scenario
2:01 API response dependencies
2:28 syntax of dispatch group
4:03 FYI before using dispatch group
4:27 dispatch group demo
10:07 calling leave inside closure
11:22 code refractor
12:23 xcode tip for thread debugging

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

✅ Subscribe to the channel and stay ahead of everyone by following the right way for writing clean code in swift. 🔥🔥🔥🔥🔥

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-----------------------------------------------------------------------------------------------------------------------
📥 Download the source code from

-----------------------------------------------------------------------------------------------------------------------

############################################

Connect with me on social media

###########################################
#dispatchGroup #gcdDispatchGroupInSwift5 #swiftHindiTutorials
Рекомендации по теме
Комментарии
Автор

Huge Respect for Ravi Sir, He is genius Guy, With the help of him videos related to an iOS, I was selected in reputed company, and now I have around 2year of experience and salary package is also great . all credit to Ravi sir. Salute to this man bcz I was selected in covid time and also I supported to my family with my earning. Again Really thanks from my heart. :)))

MandeepSingh-lyjj
Автор

This is really great Ravi since the day i started watching your videos, day to day im getting close to swift . please keep making videos more on regular basis . so that we can learn more n more from you .

AnshikaPathak-mnej
Автор

never thought this scenario can be handled so easily with DG. Take a bow man. 👏

polu
Автор

Very informative and explained in very simple way.

ganeshwaghmode
Автор

My favourite YouTuber 👍👍👍👍 I have so much these scenarios in our app

JunaidKhan-nytu
Автор

in this example, we are entering and leaving DG 2 times, so will notify called 2 times?

anonymoussunny
Автор

This is what I was looking for. Thanks 😎

AIFunWithRakesh
Автор

Clean and neat way of handing multiple api calls on a screen. A thing to note here is when you have several different types of api calls, and assume if 1 of those calls don't return a response due to some issue ( say bug in server code), 1 dispatchQueue.leave() call will be missed out of n calls and even if remaining n-1 are executed, still there'll be no output on screen because dispatchGroup.notify() is not called unless the the number of enters match number of leave calls. This is the most important thing to be taken care of while using DispatchGroup.

darshantelang
Автор

Great video for multiple api call with clean code... Great work.

shashankmishra
Автор

Super cool .. 👌👌 ... As always you are ...

I have question here, Instead of direct initialise DispatchGroup can we create wrappper for it with Lazy and as per our need we can call in our code ?

other question is, How can i setup swagger part for testing my API ? If possible need your support

Thanks

rachitsharma
Автор

very informative video sir, I like the way you created array of requests. Previously I tried to add the dispatch group but didn't add due to miss information. Thanks for clarifying everything.

rjlove
Автор

Hello Rahul,
Nice to see your all hard work on explaining all things about Swift and SwiftUI and most of your explanation outside the code. For the last couple of months, I am following all the videos till up to date. Many things now I clearly understand. Thank you. Well, please explain on concept of semaphore in GCD and as well as with Dispatch Queue Label. If possible, I am looking for an explanation about these also. Thanks in advance.

shubhambhadauria
Автор

thanks sir really good video i am learn more ..

ramanihitesh
Автор

Thanks for this video bro. I guess next topic will be on operation queues to handle dependencies. Also make a video on DispatchSemaphore and compare it with DispatchGroups. ✌🏻

iamwaseem
Автор

Nice tutorial. Can you make video on multiple images upload along with other parameters using alamofire

NishantNarola
Автор

Sir dispatch group main ma chahta hoon k meri pahi query ka response jab aye tu tab dosri query update ho wo kase karain ge

MAbbas-ihsz
Автор

Dispatch Group is blocked thread is there any other way for async api call with same scenario

Please make video for other ways to do api calls handling

ParthPatel-ctvz
Автор

Hi.. in my App i m hitting multiple Api's and saving there Json responce in Code Data but i m getting an error
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)


so can you please tell how can i handle this error

princemehra
Автор

can you put some light on Static Dispatch and Dynamic dispatch in any of your video?

rjlove
Автор

What about thread safety here. Assuming we have 100 department for which we need to fetch data. The response of those data need to add into an array from different threads. Arrays are not thread safe will it not crash or create issue on data show.

himanshukumar_
visit shbcf.ru