每一次循环中把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";
}
}
)
解决方案 »
- UILabel内容更新问题
- [@"Hello" drawAtPoint] 如何设置字体颜色
- 菜鸟请教cell设计问题
- 关于object C的问题,求了解,谢谢
- IOS越狱开发Hello World
- tableView往下拉程序就crash掉了,EXC_BAD_ACCESS.
- Socket超时时会崩溃!try catch语句也不能捕获!
- 求助:Xcode工具栏异常、无法发布app
- 求解: js 中 stylesheets 的 rules(cssrules) 为Null,只给了一个href
- 16进制转10进制怎么得到负数
- 怎么找到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]]; }