我正在玩这个代码,它在iPhone模拟器中不起作用。
-(NSString *)localFilePath:(BOOL)forSave {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documentsPath = [documentsDirectory stringByAppendingPathComponent:@"msaas.config.xml"];
if (forSave || [[NSFileManager defaultManager] fileExistsAtPath:documentsPath]) {
return documentsPath;
}
else {
return [[NSBundle mainBundle] pathForResource:@"msaas.config" ofType:@"xml"];
}
}
是因为模拟器没有像iPhone这样的目录吗?