dispatch_async 与 NSThread 创建一个任务(更新界面)
来源:互联网 发布:手机像素绘画软件 编辑:程序博客网 时间:2024/06/02 23:21
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
-
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
- MBProgressHUD *mbp = [MBProgressHUD showHUDAddedTo:self animated:YES];
- mbp.labelText = @" 解压中,请等待... ";
- });
-
-
-
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
- [MBProgressHUD hideHUDForView:self animated:YES];
- });
-
- });
- - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
-
- if (buttonIndex == 0) {
-
-
- MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
- hud.labelText = kDelTipsLabelForMBProgressHUD;
- [NSThread detachNewThreadSelector:@selector(delTargetBook) toTarget:self withObject:nil];
-
- }
- }
-
- -(void)delTargetBook
- {
- NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
-
-
-
-
- [self performSelectorOnMainThread:@selector(didDelTargetBook) withObject:nil waitUntilDone:NO];
- [pool release];
- }
-
- -(void)didDelTargetBook
- {
- [MBProgressHUD hideHUDForView:self animated:YES];
-
- if ([delegate_ respondsToSelector:@selector(btnOfLibraryBookWasDelete:)]) {
-
- [delegate_ btnOfLibraryBookWasDelete:self];
- }
- }