我要在 Document 文件夹中创建 plist 文件,我想在 NSDictionary 中调用和存储数据,但我不知道使用什么语法???
我的 plist 文件是字典类型。
这是我的代码:
#define DOC_DIR [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
NSString *item = @"Content";
array = [[NSMutableArray alloc]init];
for (int i =0; i<8; i++) {
[array addObject:item];
}
NSLog(@"array : %@",array);
[self WriteDataToPlistFromArray:array];
- (void)WriteDataToPlistFromArray:(NSArray*)dataArray
{
NSDictionary *dic = [NSMutableDictionary dictionaryWithObjectsAndKeys:dataArray,@"Root", nil];
NSString *Path = [DOC_DIR stringByAppendingPathComponent:@"mamal.plist"];
[dic writeToFile:Path atomically:YES];
NSLog(@"%@",dic);
NSLog(@"%@",Path);
}
I want call plist from Document Folder and show data in it.