0

I have used the
dispatch_sync(kBgQueue, ^{ });

to get response from webservice at background. While getting the response at background the UI getting delay, ie) while typing the on uitextview the keyboard getting freeze at moment.

How to fix this issue?

Thanks in advance..

Janztks
  • 1
  • 1

2 Answers2

2

dispatch_sync will wait for the block to be executed (which is going to take time depending upon the operation). This blocks the main thread where the UI is updated.

In order to get a responsive UI you need to replace dispatch_sync with dispatch_async.

Rishab
  • 1,901
  • 2
  • 18
  • 34
1

right code:

dispatch_async(kBgQueue, ^{ });

dispatch_sync Submits a block object for execution on a dispatch queue and waits until that block completes.So it will block your main thread.

for move, see this

Community
  • 1
  • 1
zhungxd
  • 31
  • 3