新手问题 - 但很需要答案......在这个循环中,字符串变量lineString有时会为null,有时会在其末尾附加额外的乱码。如果有人能够解释为什么会这样,我将不胜感激....在此先感谢:
NSMutableArray* lineStrings = [[NSMutableArray alloc] initWithArray:[fileContents componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]]];
NSMutableArray *linestoJoin = [[NSMutableArray alloc] init];
int i = 0;
for (NSString *currentLine in lineStrings) {
NSArray *arr = [currentLine componentsSeparatedByString:@","];
NSString *TSN = (NSString *)[arr objectAtIndex:0];
NSString *speciesName = (NSString *)[arr objectAtIndex:1];
//This stringByAppendingString sometimes results in added garbage or nothing at all!!
NSString *lineString = [[speciesName stringByAppendingString:@"," ] stringByAppendingString:TSN];
[linestoJoin addObject:lineString];
i++;
}