均是 在沙盒目录,只是 在沙盒的 路径 不同,
1, 项目 app 路径,
NSString* path = [[NSBundlemainBundle] pathForResource:@"functionList.json"ofType:@""];
NSString* jsonString = [[NSStringalloc] initWithContentsOfFile:path encoding:NSUTF8StringEncodingerror:nil];
2,document 目录
+ (NSString*)documentDirectory
{
// static NSString *documentPath = @"/Users/majianglin/Desktop";
staticNSString *documentPath = nil;
if (documentPath == nil)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
documentPath = [paths objectAtIndex:0];
}
return documentPath;
}