我试图在我的表视图中包含大中央调度。我有一个属性:NSArray *topPlaces
TableView在实现GCD后出现空
topPlaces
是来自Flickr查询的字典数组。这需要一些时间来执行,所以我想把它放在一个单独的线程上。该表使用topPlaces
来填充表格的每一行(注意:该表格是加载应用程序时出现的第一个视图)。因为有几个方法调用getTopPlaces,所以在topPlaces未初始化的情况下,我在getTopPlaces中做了一个懒惰的实例化。我的代码目前:
- (NSArray *)getTopPlaces
{
if (!_topPlaces)
{
dispatch_queue_t downloadrQueue = dispatch_queue_create("lister downloader", NULL);
dispatch_async(downloadrQueue, ^{
_topPlaces = [FlickrFetcher topPlaces];
dispatch_async(dispatch_get_main_queue(), ^{
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"_content" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSArray *flickrTopPlacesAlphabetic = [_topPlaces sortedArrayUsingDescriptors:sortDescriptors];
_topPlaces = flickrTopPlacesAlphabetic;
});
});
dispatch_release(downloadrQueue);
}
return _topPlaces;
}
我试图解决的主要问题是,当一个行被选中时,它延续到一个新的表视图。但是当我选择一行时,它会冻结几秒钟,直到新表加载。我希望用户即使在选中该行并准备继续时也能够滚动。任何帮助将不胜感激。
如果您有与该问题有关的其他信息,请尝试编辑该问题,而不是下次回答问题:) – 2012-07-24 02:41:32
我还没有销售代表。但是,感谢指针。 – 2012-07-24 05:01:45