NSString *path = @"/Users/dlios/Desktop/OC5_省市区数组/OC5_省市区数组/area.txt";
NSString *str = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSLog(@"\n%@", str);
NSArray *strArr = [str componentsSeparatedByString:@"\n"];
for (NSString *temp in strArr) {
NSLog(@"%@", temp);
}
NSMutableArray *china = [NSMutableArray array];
for (NSString *temp in strArr) {
NSMutableArray *province = [NSMutableArray array];
[china addObject:province];
NSMutableArray *city = [NSMutableArray array];
[china addObject:city];
NSMutableArray *area = [NSMutableArray array];
[city addObject:area];
if (![temp hasPrefix:@" "]) {
NSMutableArray *province = [china lastObject];
[province addObject:temp];
NSLog(@"%@", temp);
} else if ([temp hasPrefix:@" "] && ![temp hasPrefix:@" "]) {
NSMutableArray *city = [china lastObject];
[city addObject:temp];
NSLog(@"%@", temp);
} else if ([temp hasPrefix:@" "]) {
NSMutableArray *area = [china lastObject];
[area addObject:temp];
NSLog(@"%@", temp);
}
}