2011-07-25 37 views
0

我有代碼以下行來從我的應用程序開始多次下載。問題是,NSInvocationQueue沒有調用選擇器方法,即下載我的視頻使用NSOperationQueue的多視頻下載

任何人都可以讓我知道,下面的代碼究竟出了什麼問題?

- (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]; 
    } 
+0

您是否看到(多個)內存泄漏?因爲我認爲我是。 –

+0

@Jacob:是的!或者,也許是時候開始習慣ARC問題了...... – jtbandes

+0

@jtbandes:啊! ;) –

回答

0

您已暫停您的隊列。

您添加到掛起隊列的操作未運行。這可能是你的問題,除非你在其他地方開始排隊。

+0

謝謝Abizern,該方法開始執行,因爲我已經刪除了[operationQueue setSuspended:YES] ;. –

+0

爲了維護NSOperationQueue,上下文中都提到了兩個問題。由於我將使用此代碼下載多個視頻,因此在下載視頻比賽後,如何從NSOperationQueue刪除/釋放添加NSInvocationOperation?而且,如果我想停止下載特定視頻,該怎麼辦? –