我有一个NSMutableArray
里面的物品。我想将每个项目与一个字符串进行比较。如果字符串相同,则数组的下一项应存储在另一个数组中。
NSString *string2 = [NSString stringWithFormat:@"Period:"];
// Filtern nach Periode
NSMutableArray *Eventarray =[NSMutableArray array];
for(int i=0;i<[lines count]; i++)
{
NSMutableString *string1 = [NSMutableString stringWithFormat: @"%@",[[lines objectAtIndex:i]description]];
// NSLog(@"%@",string1);
int index = [[lines objectAtIndex:i] indexOfObject:@"Period:"];
NSLog(@"%@",index);
if ([[lines objectAtIndex:i] isEqualToString:@"Period:"])
{
//strings are same
NSLog(@"ii");
NSLog(@"ii");
int e=i+1;
NSMutableString *Periode = [NSMutableString stringWithFormat: @"%@",[lines objectAtIndex:e]];
[Eventarray addObject:Periode];
}
[string1 deleteCharactersInRange:NSMakeRange([string1 length]-1, 1)];
}
for(int i=0;i<[Eventarray count]; i++)
{
NSLog(@"Eventarray: %@", [Eventarray objectAtIndex:i]);
}
数组如下所示:
2013-08-12 13:31:35.375 xxxx[3809:207] PublishedRoster
2013-08-12 13:31:35.376 xxxx[3809:207] Period:
2013-08-12 13:31:35.377 xxxx[3809:207] 25Jul2013-08Sep2013
我尝试了一切,但我不知道出了什么问题。我错过了什么?