Start a new topic

Asynchronous KCSQuery

 Hi, recently I have started using the KCSQuery in Swift to get data from the database. However, since all the methods are asynchronous, I can only get the data I want in the completion blocks.

Is there any way to make the query synchronous so the programwaits for the data to be retrieved before moving on to the next line of code?


Can you explain in detail why you would want these calls to be synchronous?



Sometimes I need to verify the data retrieved from the database before continuing to the next function and the only way I can do it now is to put everything including other KCSQuery into the completion block. I am just wondering if that's the right way to do it because nested completion blocks look very messy.



Kinvey queries work in asynchronous way. We should avoid using synchronous as it blocks main thread until the request is completed. You have done it in the correct way by using nested completion blocks.

Please let me know if you have any other query.



Login or Signup to post a comment