Having a problem with reading a file using NSString initWithContents OfFile
Posted
by srikanth rongali
on Stack Overflow
See other posts from Stack Overflow
or by srikanth rongali
Published on 2010-04-01T05:55:27Z
Indexed on
2010/04/01
6:23 UTC
Read the original article
Hit count: 229
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.
© Stack Overflow or respective owner