I am working with NSScanner to parse data that is both comma and line delimited. It was fairly straightforward to implement, but I am running into a very simple issue. I would like to scan in the next line, even if it is empty. The problem I am having now is that if there is an empty line, it will skip it and read the next line in. Then my parsing is off because the wrong data ended up in the wrong place. Here is the code I have now:
NSCharacterSet *setToIgnore = [NSCharacterSet characterSetWithCharactersInString:@",\r\n"];
[scanner setCharactersToBeSkipped:setToIgnore];
NSInteger levelID, campaignID;
NSString *title, *about, *gameBoard;
BOOL aTest = [scanner scanInteger:&levelID] && [scanner scanInteger:&campaignID];
aTest = [scanner scanUpToString:@"\r\n" intoString:&title];
aTest = [scanner scanUpToString:@"\r\n" intoString:&about];
aTest = [scanner scanUpToString:@"\r\n" intoString:&gameBoard];
So the data is formatted like so: int,int string string string
Sometimes, the second string (about) is empty, and NSScanner skips it and reads the gameBoard string into about. How do I tell NSScanner to read in the next line?