Check Mobile App
Read now
Start a Project

Observe whether All Operation is completed or not using swift 4.2

Save

All Operation is completed or not

In iOS basically we perform the background thread operation using GCD & OPeration, OPerationQueue.

In GCD there is DispatchGroup for handling the work is completed or not (different DispatchWorkItem ).  In Operation, there is no kind of facility for this we have to create KVO

to manage all things. here we have taken the example of 2 Operation each Operation is downloading the image.

Please follow these steps:

1: First Create Operation class that will download the image.

 

2: Take a controller class and Declare  OperationQueue.

Notes: It will add all the operations in the queue.

3: Write the function for operation.

Note: here op1 & op2 is separate completion of the operation.

4: Now Observe all the operation is completed or not.

Write this code in your class.

Now: Here we have implemented KVO to check whether the Queue contains operation or not.

Complete Code :

 

Reference:

Recent Xcode, iOS and Swift Blog posts

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Excellent work, fast, good quality and understood the brief perfectly! Quick responses developing the project and very good cooperation. I suggest to anyone.

Stathis Plakidas

Stathis Plakidas

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home