【发布时间】:2012-07-03 15:15:22
【问题描述】:
我正在使用以下代码行::
- (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);
}
edit.txt的内容是:
= WWWW =
[[Category:ssss]]
我要做的是从文件edit.txt 中读取并将其内容存储在一个字符串中。但是,在 NSLogging 上,我得到 null 对应的 saveString。
我在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`
有人可以帮我解决错误吗?我无法弄清楚。谢谢和问候。
【问题讨论】:
-
为什么您的
savedName参数为空?你应该先检查一下。 -
它不为空.. 它是
xxxx -
哦,我把 saveName 和 saveString 搞混了,没关系
-
对不起..但我不认为这是重复的!
标签: iphone objective-c ios xcode ipad