我正在通过下载视频开发应用。当我下载第一个索引视频时,它的工作正常。但是除了这个视频我正在下载。它崩溃了。我的错误显示是:
' NSRangeException',原因:' * - [__ NSArrayM objectAtIndex:]:索引1超出界限[0 .. 0]'" *
-(void)clickbtn:(id)sender{
btnTag =[sender tag];
NSLog(@"%d",btnTag);
NSLog(@"tag number is = %ld",(long)[sender tag]);
NSString *vedioUrl =[[allData objectAtIndex:btnTag]valueForKey:@"video"];
NSLog(@"%@",vedioUrl);
NSString *encodeUrl = [vedioUrl stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding];
NSLog(@"%@",encodeUrl);
NSURL *url = [NSURL URLWithString:encodeUrl];
NSLog(@"%@",url);
self.downloadManager = [[DownloadManager alloc] initWithDelegate:self];
self.downloadManager.maxConcurrentDownloads = 4;
[self.downloadManager addDownloadWithFilename:downloadFilename URL:url];
self.startDate = [NSDate date];
[self.downloadManager start];
UIButton *button1 = (UIButton*)sender;
NSLog(@"%@",button1);
CGPoint buttonPosition = [sender convertPoint:CGPointZero
toView:self.Table];
NSIndexPath *clickedIP = [self.Table indexPathForRowAtPoint:buttonPosition];
NSLog(@"%@",clickedIP);
DownloadCell *cell = (DownloadCell *) [self.Table cellForRowAtIndexPath:clickedIP];
NSLog(@"%@",cell);
Download *download = self.downloadManager.downloads[clickedIP.row];
NSLog(@"%@",download);
if (download.isDownloading)
{
[self updateProgressViewForIndexPath:clickedIP download:download];
}
else
{
cell.progressView.hidden = YES;
}
}
答案 0 :(得分:0)
您正在尝试从数组中获取值,该值仅包含0 index
处的一个值或该特定数组已为空。当您尝试从table-view
中选择第二个单元格时,尝试从index 1
的数组中获取值。但实际上在数组中index 1
没有任何值。这就是你的应用程序崩溃的原因。
请先使用 NSLog 验证您的阵列是否已根据您的要求完全填充。