使用 NSOperationQueue 下载多个视频
我有以下几行代码可以从我的应用程序开始多次下载。问题是,NSInitationQueue 没有调用选择器方法,即 downloadMyVideos。
请问有人可以告诉我以下代码到底有什么问题吗?
- (void)viewWillAppear:(BOOL)animated
{
[operationQueue cancelAllOperations];
operationQueue = [[NSOperationQueue alloc] init];
[operationQueue setSuspended:YES];
indexOperation = [[NSInvocationOperation alloc]initWithTarget:self selector:@selector(downloadMyVideo) object:nil];
[operationQueue addOperation:indexOperation];
}
I have code following lines to start multiple downloads from my application. The problem is, the NSInvocationQueue is not calling selector method, i.e. downloadMyVideos.
Can please anyone let me know, exactly what is wrong with following code?
- (void)viewWillAppear:(BOOL)animated
{
[operationQueue cancelAllOperations];
operationQueue = [[NSOperationQueue alloc] init];
[operationQueue setSuspended:YES];
indexOperation = [[NSInvocationOperation alloc]initWithTarget:self selector:@selector(downloadMyVideo) object:nil];
[operationQueue addOperation:indexOperation];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已暂停队列。
添加到挂起队列的操作不会运行。这可能是你的问题,除非你在其他地方开始排队。
You've suspended your queue.
Operations that you add to a suspended queue are not run. That could be your problem, unless you are starting the queue elsewhere.