Having a problem with reading a file using NSString initWithContents OfFile
- by srikanth rongali
In this program when I debug, it is showing the nil for fileNameString. I could not understand what is the problem. Please help me ?
@implementation fromFileRead1
NSString *fileNameString;
-(id)init
{
if( (self = [super init]) )
{
fileNameString = [[NSString alloc] initWithContentsOfFile: @"enemyDetails.rtf" encoding:NSUTF8StringEncoding error:nil];
NSArray *lines = [fileNameString componentsSeparatedByString:@"\n"];
for (id *line in lines)
{
NSLog(@"Line1%@", line );
}
}
return self;
}
@end
Thank You.