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.
-(id)init
{
if( (self = [super init]) )
{
NSString *path = @"/Users/sridhar/Desktop/Projects/exampleOnFile2/enemyDetals.txt";
NSString *contentsOfFile = [[NSString alloc] initWithContentsOfFile:path];
NSArray *lines = [contentsOfFile componentsSeparatedByString:@"\n"];
for (id *line in lines)
{
NSLog(@"Line1%@", line );
}
}
return self;
}
@end