我只想将静态plist数据替换为dynamic.t这是我的代码
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *docDirPath = [documentsDirectory stringByAppendingPathComponent:@"sample.plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if(![fileManager fileExistsAtPath: docDirPath])
{
NSString *bundle = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"plist"];
[fileManager copyItemAtPath:bundle toPath:docDirPath error:&error];
NSLog(@"plist is copied to Directory");
}
我在事件数组中有一些数据但是没有写/读你可以告诉我我错在哪里。
NSLog(@"data coming from server....%@",self.eventDataArray);
//Writing array to document directory
NSArray *docpaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [docpaths objectAtIndex:0];
NSString *path = [NSString stringWithFormat:@"%@/sample.plist", documentsDirectoryPath];
[self.eventDataArray writeToFile:path atomically:YES];
NSLog(@"plist path string....%@",path);
//reading from document directory
NSMutableArray *readingArray=[[NSMutableArray alloc] initWithContentsOfFile:path];
NSLog(@"plist reading data is here......%@",readingArray);