Managing CPU intensive threads on iOS

前端 未结 4 1297
清歌不尽
清歌不尽 2021-01-05 11:35

I’m an experienced C/C++ programmer coming up to speed on Objective C on the iPhone. I have done a lot of searching, but haven’t found a satisfactory answer on what must be

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-05 12:22

    Here you are my answers to your questions.

    1) Since you are an experienced C programmer, you will feel comfortable with Grand Central Dispatch (GCD), a C based API for concurrency.

    2) With GCD, you do not need to sleep at all. Simply dispatch asynchronously the work you need to do in a queue using the maximum priority (DISPATCH_QUEUE_PRIORITY_HIGH).

    3) When you need to update the UI, simply dispatch on the main queue ( within the same block doing the work, using dispatch_get_main_queue() ) the UI update as needed.

    Take a look at the relevant GCD documentation here.

提交回复
热议问题