1

我正在发出服务器请求以使用以下代码填充表格视图:

当前的问题是,发出此请求的视图在用户调用时需要很长时间才能从前一个视图加载。如何将其排队以便加载视图然后表加载数据?我试过移动, [self citySearchArrayMethod];但视图加载速度很快,但表是空的。

dispatch_queue_t jsonParsingQueue = dispatch_queue_create("jsonParsingQueue", NULL);

// execute a task on that queue asynchronously
dispatch_async(jsonParsingQueue, ^{


    // some code on a main thread (delegates, notifications, UI updates...)
    dispatch_async(dispatch_get_main_queue(), ^{

        [self citySearchArrayMethod]; // populates the city table with city list

    });
});
4

1 回答 1

1
dispatch_queue_t jsonParsingQueue = dispatch_queue_create("jsonParsingQueue", NULL);


// execute a task on that queue asynchronously
dispatch_async(jsonParsingQueue, ^{

      [self citySearchArrayMethod]; // populates the city table with city list

    // some code on a main thread (delegates, notifications, UI updates...)
    dispatch_async(dispatch_get_main_queue(), ^{

      [self.tableView reloadData]; // load the table with data

    });
});
于 2013-11-13T12:07:31.450 回答