can anyone tell me the function of following code. is the code line
NSString* fileName = @"text.txt";
used for reading the file from a location in the system?
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString* fileName = @"text.txt";
NSString *fileString = [NSString stringWithContentsOfFile: fileName];
NSArray *lines = [fileString componentsSeparatedByString:@"\n"];
[pool drain];
return 0;
}
fileName is a string that has will return you the following output
This is because you have assigned that value to it read your code once more.
If you want to store the reference of some file that is inside your bundle then in that case i would suggest using the NSBundle class refer to Rams answer and get the job done buddy
Thanks and Regards