现在我移动到集合视图projects.in他们获取一些数据并在集合视图中显示。并且在viewdidload方法中,他们做了一些事情,但不能得到那个。这就是代码:
- (void)viewDidLoad {
[super viewDidLoad];
//section name
// display the title in collection view
titleArray = [NSMutableArray array];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
//Background Tasks
// get data is a method which have all declaration and process for get the data and display in collection view from url using HTTP GET METHOD
[self getdata];
dispatch_async(dispatch_get_main_queue(), ^(void){
//Run UI Updates
[self.mycollectionView reloadData];
});
});
self.mycollectionView.dataSource = self;
self.mycollectionView.delegate = self;
}
2。我怀疑是;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){
//Background Tasks
[self getdata];
dispatch_async(dispatch_get_main_queue(), ^(void){
//Run UI Updates
[self.mycollectionView reloadData];
});
});
为什么他们在getdata, relode
内使用dispath
方法。请解释一下他们在dispath
内部使用的原因。请不要投票。我已经开始学习了。需要帮助吗?
谢谢!