【IOS】异步调用--- 简单使用记录

/××
×实现功能:店铺被删除后,先显示提示toast.然后,页面休眠5秒后,再返回到店铺列表页面。
×/ - (void)processDeleteShopError
{
_isLoadingData = NO;
[_tableView refreshScrollViewDataSourceDidFinishedLoading:_tableView];
[self showToast:@"店铺被删除,返回店铺列表页面刷新数据"];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, );
dispatch_async(queue, ^{
[NSThread sleepForTimeInterval:5];
dispatch_async(dispatch_get_main_queue(), ^{
[self backToPreController];
});
});
} - (void)backToPreController
{
[_shopEditDelegate shopDeleted:_shop];
[self.navigationController popToRootViewControllerAnimated:YES];
}

注意和以下代码比较,其效果不一样。

- (void)processDeleteShopError
{
_isLoadingData = NO;
[_tableView refreshScrollViewDataSourceDidFinishedLoading:_tableView];
[self showToast:@"店铺被删除,返回店铺列表页面刷新数据"]; [[NSThread alloc]performSelector:@selector(backToPreController) withObject:nil afterDelay:];
} - (void) backToPreController
{
[_shopEditDelegate shopDeleted:_shop];
[self.navigationController popToRootViewControllerAnimated:YES];
}
上一篇:Android SDK开发常用工具的使用及其异常处理


下一篇:配置Android SDK 开发环境(转)