Objective C wait until an asynch task has been processed

后端 未结 2 2035
甜味超标
甜味超标 2021-01-25 21:36

In my code, I am running a local server (CocoaHTTPServer). When the server receives a request, it creates a thread and passes control to a certain method ( - (NSObject<

2条回答
  •  感情败类
    2021-01-25 21:55

    NSRunLoop has a method called runUntilDate: which should work for you with dates in near future like 1s ahead or so. That way you can replace your sleep call in the while loop for example with:

    [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeintervalSinveNow:1]
    

提交回复
热议问题