Possible Duplicate:
Read Text file Programmatically using Objective-C
I am using the following lines of Code ::
- (void)sync:(NSString *)savedName{
NSLog(@"saved name is this :: %@", savedName);
NSString *savedDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *saveFilePath = [savedDir stringByAppendingPathComponent:savedName];
saveFilePath = [saveFilePath stringByAppendingPathComponent:@"edit.txt"];
NSString *saveString = [NSString stringWithContentsOfFile:saveFilePath encoding:NSUTF8StringEncoding error:nil];
NSLog(@"saveString is :: %@ savedName : %@ savefilepath : %@", saveString, savedName, saveFilePath);
}
The contents of edit.txt
is :
= WWWW =
[[Category:ssss]]
What I am trying to do is to read from the file edit.txt
and store its contents in a string. However, on NSLogging, I get null
for saveString
.
I got the following output at gdb
::
splitView[838:f803] saveString is :: (null) savedName : xxxx savefilepath : /Users/xxxx/Library/Application Support/iPhone Simulator/5.1/Applications/D4B3A4CF-E7D0-4D25-B3D3A170A329/Documents/xxxx/edit.txt`
Can someone help me to sort out the error ?? I am unable to figure it out. Thanks and Regards.