Yes, + (id)stringWithContentsOfFile:(NSString *)pathout of date.
See Apple documentation for NSString
Use instead + (id)stringWithContentsOfFile:(NSString *)path encoding:(NSStringEncoding)enc error:(NSError **)error
Use the following:
lines = [[NSString stringWithContentsOfFile:@"testFileReadLines.txt"
encoding:NSUTF8StringEncoding
error:nil]
componentsSeparatedByString:@"\n"];
Update: - thanks to JohnK
NSCharacterSet *newlineCharSet = [NSCharacterSet newlineCharacterSet];
NSString* fileContents = [NSString stringWithContentsOfFile:@"testFileReadLines.txt"
encoding:NSUTF8StringEncoding
error:nil];
NSArray *lines = [fileContents componentsSeparatedByCharactersInSet:newlineCharSet];
source
share