我已将plist中的JSON数据存档为数据抽象类型。 我的plist格式是:
`<dict>
<key>
<array>
<data>
4352ght4 qwe435g5 yu67k10p
</data>
</array>
</key>
<key>
<array>
<data>
4352ght4 qwe435g5 yu67k10p
</data>
</array>
</key>
<key>
<array>
<data>
4352ght4 qwe435g5 yu67k10p
</data>
</array>
</key>
</dict>`
此数据类型包含长JSON条目。如何从此属性列表中获取数据并将其显示在表中。 我还准备了.h和.m类来获取数据。
答案 0 :(得分:0)
NSString * plistFilePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)objectAtIndex:0] stringByAppendingPathComponent:@“plist.plist”];
NSDictionary *list = [NSDictionary dictionaryWithContentsOfFile:plistFilePath];
NSLog(@"%@",list);
for (id key in list) {
NSArray *array = [list objectForKey:key];
timesheetObject *timeobject = [timesheetObject alloc];
for(int i=0;i<array.count ;i++)
{
timeobject = (timesheetObject *)[NSKeyedUnarchiver unarchiveObjectWithData:[array objectAtIndex:i]];
NSLog(@"%d",timeobject.taskId);
NSLog(@"Start time %@",timeobject.startTime_actual);
NSLog(@"End Time %@",timeobject.endTime_actual);
[self.objectHolderArray addObject:timeobject];