문제

I am adding a block to a queue (not the main queue), using Grand Central Dispatch. This block has a loop and between every passage of the loop a small delay of 0,02 seconds is required. I am using

dispatch_async(myOwnQueue, ^{
  // begin loop
  // do stuff
  usleep(20000);
  // end loop
});

on this queue. As it is not the main queue, it will not block the main thread.

The problem is that Xcode complains: warning: implicit declaration of function 'usleep'

Is there other way to do that?

thanks.

도움이 되었습니까?

해결책

You just need to include the appropriate header before calling usleep():

#include <unistd.h>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top