我将文件写入应用程序的文档目录:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// the path to write file
NSString *file = [documentsDirectory stringByAppendingPathComponent:@"data.json"];
[responseString writeToFile:file atomically:YES];
但是我怎样才能访问该文件?
我的代码如下所示:
NSString *filePath = [[NSFileManager defaultManager] pathForRessorce: @"data" ofType:@"JSON"];
NSString *fileContent = [[NSString alloc] initWithContentsOfFile:filePath];
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *data = (NSDictionary *) [parser objectWithString:fileContent error:nil];
文件路径未填充...有人可以给我一个提示吗?
谢谢!