您的位置:首页 > 移动开发 > IOS开发

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

2013-12-20 17:03 344 查看
/××
×实现功能:店铺被删除后,先显示提示toast.然后,页面休眠5秒后,再返回到店铺列表页面。
×/

- (void)processDeleteShopError
{
_isLoadingData = NO;
[_tableView refreshScrollViewDataSourceDidFinishedLoading:_tableView];
[self showToast:@"店铺被删除,返回店铺列表页面刷新数据"];
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
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:2];
}

- (void) backToPreController
{
[_shopEditDelegate shopDeleted:_shop];
[self.navigationController popToRootViewControllerAnimated:YES];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: