I’m trying to parse a string fileString:
"contact1;12312312;John\ncontact2;34243442;Bill\n"
NSArray* lines = [fileString componentsSeparatedByString:@"\n"];
In debugger array lines consists of 3 objects. Why?
[lines count] must be 2, but why does it equal 3?
NSString* line1 = [lines objectAtIndex:0];
NSString* line2 = [lines objectAtIndex:1];
NSString* line3 = [lines objectAtIndex:2];
line1 is “contact1;12312312;John”.
line2 is “contact2;34243442;Bill”.
line3 has type (_NSCFConstantString *) and doesn’t show a value in debugger.
Later I am using this array as a data source for a tableView, so I need a correct array count.
The input string has two separators and so the resulting array has three entries
In this case the third one is an empty string (NSString with length of 0)
From NSString documentation