我在这段代码中有一个错误
NSString *str = @"above string"; //load above string here
NSArray * firstArry = [str componentsSeparatedByString:@"#"];
NSMutableArray *secondArry = [[NSMutableArray alloc] init]; //Will hold the # titles
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; //Will hold the strings related to # title
for(NSString firstArryStr : firstArry)
{
NSArray *tempArry = [firstArryStr componentsSeparatedByString@"\n"];
NSMutableArray *titleStingsArry = [[NSMutableArray alloc] init];
for (int i=0; i< [tempArry count];i++)
{
if (i==0)
{
NSString *title = [tempArry objectAtIndex:i];
[secondArry addObject:title];
[dict setValue:titleStingsArry forKey:title];
} else {
[titleStingsArry addObject:[tempArry objectAtIndex:i]];
}
}
}
错误出现在第一个“for”上。
这是处理该问题的代码:
# 2012
20120604 Huge Sandstorm over Saudi Arabia
20120527 Huge Sandstorm over niger
# 2012
20110330 Huge Sandstorm over niger
# just for the test
20110330 AHuge Sandstorm over niger
20110330 BHuge Sandstorm over niger
20110330 CHuge Sandstorm over niger
20110330 1Huge Sandstorm over niger
20110330 2Huge Sandstorm over niger
20110330 3Huge Sandstorm over niger
20110330 4Huge Sandstorm over niger
20110330 5CHuge Sandstorm over niger
20110330 6Huge Sandstorm over niger
# **********
20110330 7Huge Sandstorm over niger
20110330 8Huge Sandstorm over niger
20110330 9CHuge Sandstorm over niger
20110330 AHuge Sandstorm over niger
20110330 B10CHuge Sandstorm over niger
20110330 **CHuge Sandstorm over niger
在一个UITableView
不同的部分,其中标题将是# .......
和内容20110330 ........
20110330 ........
20110330 ........
有人可以帮我吗?