Reload data of UITableView in background

前端 未结 4 926
夕颜
夕颜 2021-02-04 14:52

In my app, I have a UITableViewController.

Its tableView is divided in 3 sections.

I download datas for each of those sections from my server. To do this, I have

4条回答
  •  旧巷少年郎
    2021-02-04 15:11

    In reloadDatas method you should change this line:

    dispatch_queue_t concurrentQueue = dispatch_get_main_queue();
    

    To:

    dispatch_queue_t concurrentQueue = dispatch_queue_create("some queue", NULL);

    But when you call [myDisplayedTable reloadData], you need to call this operation in the main queue.

    dispatch_async(dispatch_get_main_queue(), ^{ [myDisplayedTable reloadData]; });
    

提交回复
热议问题