NSInvocationOperation的cancelAllOperations不会取消正在运行的operation
来源:互联网 发布:ubuntu 桌面假死 编辑:程序博客网 时间:2024/06/07 00:22
原来以为cancelAllOperations时,正在运行的operation的会停止,旦实际发现是不会的。
并且在operation运行结束前,ViewController是不会dealloc的。
实际上,cancelAllOperations的作用是将在队列里排队的operation从对列里移除。
测试代码如下:
#import "ViewController.h"
@interface ViewController ()
@property (retain,nonatomic)NSOperationQueue *pQueue;
@end
@implementation ViewController
- (void)viewDidLoad
{
[superviewDidLoad];
self.pQueue =[[NSOperationQueuealloc]init];
NSInvocationOperation *Invocation = [[NSInvocationOperationalloc]initWithTarget:selfselector:@selector(downLoadImage)object:nil];
[self.pQueueaddOperation:Invocation];
UIButton* btn = [UIButtonbuttonWithType:UIButtonTypeRoundedRect];
btn.frame =CGRectMake(10,100,300, 30);
[btn setTitle:@"pop back"forState:UIControlStateNormal];
[btn addTarget:selfaction:@selector(popBack)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:btn];
}
-(void)popBack{
[self.pQueuecancelAllOperations];
[self.navigationControllerpopViewControllerAnimated:YES];
}
-(void)dealloc{
NSLog(@"ViewController dealloced");
}
- (void)downLoadImage
{
sleep(5);
NSLog(@"operation ended");
}
@end
- NSInvocationOperation的cancelAllOperations不会取消正在运行的operation
- 取消正在运行的存储过程
- NSOperationQueue 的 cancelAllOperations
- ASINetworkQueue使用cancelAllOperations方法来取消下载时使用的注意点
- SAS取消正在运行的语句——Run Cancel
- 正在运行的SQL
- 取消outlook正在发送的邮件
- 取消正在执行的Linux命令
- ASINetworkQueue使用cancelAllOperations方法来取消下载时使用的注意点 在 ASIHTTPRequest V1.7前提下 正确使用: imgDataDownLo
- 关于NSOperationQueue 里面的 cancelAllOperations 无效的解决方法
- 删除正在运行的数据库
- 查询正在运行的SQL
- 列出正在运行的程序
- 挂起正在运行的线程
- 查找正在运行的进程
- 停正在运行的job
- 删除正在运行的procedure
- 取得正在运行的Activity
- Eclipse :Access restriction: The type JPEGImageEncoder is not accessible due to restriction on requi
- [Eclipse]_[显示gc按钮减少内存占用]
- java中集合的遍历
- Hbase 介绍
- 【IOS基础知识】格式输出
- NSInvocationOperation的cancelAllOperations不会取消正在运行的operation
- JAVA EL表达式详细介绍使用手册
- C/C++ 直接传值,传引用,传指针的理解
- 17--2--5求字符串长度
- 自己做个时钟改进版-html5的canvas
- Ubuntu 12.04下安装gnome桌面
- sizeof与strlen
- mysql获取当前时间、秒数
- window7,xp通过cmd 设置ip地址与自动获取ip地址