每一次循环中把rowsVideoFileChapter变量结果赋给一个rowsVideoFile字典对象后没有清空,导致后面循环中又不断地增加,但是添加removeAllObject过后章节的类容都没有了。
NSMutableArray *rowsVideoFileChapter = [[NSMutableArray alloc]init];
NSMutableArray *rowsVideoFile = [[NSMutableArray alloc]init]; //rowsVideoFileChapter =NULL;
for(NSInteger iTemp1 = 1; iTemp1 <= 4; iTemp1++) {
for (NSInteger iTemp11 = 1; iTemp11 <= 4; iTemp11++) {
[rowsVideoFileChapter addObject:[[NSDictionary alloc] initWithObjectsAndKeys:@"1001", @"id",[NSString stringWithFormat:@"第%i章节",iTemp11] , @"title",@"60", @"position",nil]];
}
[rowsVideoFile addObject:[[NSDictionary alloc] initWithObjectsAndKeys:@"9347",@"id",[NSString stringWithFormat:@"第%i章节",iTemp1] ,@"title",@"9348-2224565.flv",@"video_path",rowsVideoFileChapter,@"rowsVideoFileChapter" ,nil]]; } NSLog(@"rowsVideoFile=%@",rowsVideoFile);为什么[rowsVideoFileChapter removeAllObject]会导致之后赋值到rowsVideoFile里的rowsVideoFileChapter的内容都会清除?
如果用removeAllObject无法实现这个功能,那么还能用什么来得到这样的结果:
id = 9347;
rowsVideoFileChapter = (
{
id = 1001;
position = 60;
title = "\U7b2c1\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c2\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c3\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c4\U7ae0\U8282";
}
);
title = "\U7b2c1\U7ae0\U8282";
"video_path" = "9348-2224565.flv";
}
id = 9347;
rowsVideoFileChapter = (
{
id = 1001;
position = 60;
title = "\U7b2c1\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c2\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c3\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c4\U7ae0\U8282";
}
);
title = "\U7b2c2\U7ae0\U8282";
"video_path" = "9348-2224565.flv";
} id = 9347;
rowsVideoFileChapter = (
{
id = 1001;
position = 60;
title = "\U7b2c1\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c2\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c3\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c4\U7ae0\U8282";
}
);
title = "\U7b2c3\U7ae0\U8282";
"video_path" = "9348-2224565.flv"; id = 9347;
rowsVideoFileChapter = (
{
id = 1001;
position = 60;
title = "\U7b2c1\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c2\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c3\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c4\U7ae0\U8282";
}
);
title = "\U7b2c4\U7ae0\U8282";
"video_path" = "9348-2224565.flv";
}
}
)
NSMutableArray *rowsVideoFileChapter = [[NSMutableArray alloc]init];
NSMutableArray *rowsVideoFile = [[NSMutableArray alloc]init]; //rowsVideoFileChapter =NULL;
for(NSInteger iTemp1 = 1; iTemp1 <= 4; iTemp1++) {
for (NSInteger iTemp11 = 1; iTemp11 <= 4; iTemp11++) {
[rowsVideoFileChapter addObject:[[NSDictionary alloc] initWithObjectsAndKeys:@"1001", @"id",[NSString stringWithFormat:@"第%i章节",iTemp11] , @"title",@"60", @"position",nil]];
}
[rowsVideoFile addObject:[[NSDictionary alloc] initWithObjectsAndKeys:@"9347",@"id",[NSString stringWithFormat:@"第%i章节",iTemp1] ,@"title",@"9348-2224565.flv",@"video_path",rowsVideoFileChapter,@"rowsVideoFileChapter" ,nil]]; } NSLog(@"rowsVideoFile=%@",rowsVideoFile);为什么[rowsVideoFileChapter removeAllObject]会导致之后赋值到rowsVideoFile里的rowsVideoFileChapter的内容都会清除?
如果用removeAllObject无法实现这个功能,那么还能用什么来得到这样的结果:
id = 9347;
rowsVideoFileChapter = (
{
id = 1001;
position = 60;
title = "\U7b2c1\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c2\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c3\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c4\U7ae0\U8282";
}
);
title = "\U7b2c1\U7ae0\U8282";
"video_path" = "9348-2224565.flv";
}
id = 9347;
rowsVideoFileChapter = (
{
id = 1001;
position = 60;
title = "\U7b2c1\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c2\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c3\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c4\U7ae0\U8282";
}
);
title = "\U7b2c2\U7ae0\U8282";
"video_path" = "9348-2224565.flv";
} id = 9347;
rowsVideoFileChapter = (
{
id = 1001;
position = 60;
title = "\U7b2c1\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c2\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c3\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c4\U7ae0\U8282";
}
);
title = "\U7b2c3\U7ae0\U8282";
"video_path" = "9348-2224565.flv"; id = 9347;
rowsVideoFileChapter = (
{
id = 1001;
position = 60;
title = "\U7b2c1\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c2\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c3\U7ae0\U8282";
},
{
id = 1001;
position = 60;
title = "\U7b2c4\U7ae0\U8282";
}
);
title = "\U7b2c4\U7ae0\U8282";
"video_path" = "9348-2224565.flv";
}
}
)
解决方案 »
- Cocos2d-x中CCScrollView如何控制触摸响应的区域??
- 用vmware虚拟机安装雪豹苹果系统的问题。
- iOS/iPhone 问题,求指导
- ios后端一般用什么开发
- 如何在其他地方获得self.navigationItem.leftBarButtonItem.title 的title值呢?
- scrollView
- 谁能简单的讲解下UICollectionView与UICollectionViewFlowLayout的使用
- 如何获取音视频文件
- iOS中tableViewCell中如何嵌套collectionView,并实现collectionView界面跳转
- 苹果UIwebView内嵌网页上js的history.back()不好用
- 怎么找到storyboard中定义的viewcontroller
- IOS应用可以调用自身的子程序吗
NSMutableArray *rowsVideoFile = [[NSMutableArray alloc]init]; //rowsVideoFileChapter =NULL;
for(NSInteger iTemp1 = 1; iTemp1 <= 4; iTemp1++) {
NSMutableArray *rowsVideoFileChapter = [[NSMutableArray alloc]init];
for (NSInteger iTemp11 = 1; iTemp11 <= 4; iTemp11++) {
[rowsVideoFileChapter addObject:[[NSDictionary alloc] initWithObjectsAndKeys:@"1001", @"id",[NSString stringWithFormat:@"第%i章节",iTemp11] , @"title",@"60", @"position",nil]];
}
亲,你是想这样实现么
[rowsVideoFile addObject:[[NSDictionary alloc] initWithObjectsAndKeys:@"9347",@"id",[NSString stringWithFormat:@"第%i章节",iTemp1] ,@"title",@"9348-2224565.flv",@"video_path",rowsVideoFileChapter,@"rowsVideoFileChapter" ,nil]]; }