不知道怎麼使用NSMutableArray
和NSArray
。
代碼:
for (int i=0; i<[DateSortArry2 count]; i++) {
for (int j=0; j<[DateSortArry2Copy count]; j++) {
NSString *sectiondateStr2 = [NSString stringWithFormat:@"%@",[DateSortArry2Copy objectAtIndex:j]];
if ([[DateSortArry2 objectAtIndex:i] isEqualToString:sectiondateStr2]) {
[Arry addObject:sectiondateStr2];
}
}
[SumArry addObjectsFromArray:Arry];
[Arry removeAllObjects];
}
代碼得到的結果:
SumArry:(
"20130227",
"20130227",
"20130227",
"20130226",
"20130226",
"20130226",
"20130225",
"20130225")
要求的結果:
SumArry:((
"20130227",
"20130227",
"20130227",
),
(
"20130226",
"20130226",
"20130226",
),
(
"20130225",
"20130225"
))
不知道應該怎麼實現。
NSString *str = @"";
for (int i=0; i<[DateSortArry2 count]; i++)
{
if (str isEqualToString:[DateSortArry2 objectAtIndex:i])
{
return;
}
else
{
NSMutableArray * Arry = [[NSMutableArray alloc] init];
str = [DateSortArry2 objectAtIndex:i]
for (int j=0; j<[DateSortArry2Copy count]; j++)
{
if ([[DateSortArry2 objectAtIndex:i] isEqualToString:str])
{
[Arry addObject:str];
}
}
[SumArry addObject:Arry];
[Arry removeAllObjects];
}
}