我使用以下代码通过 coredata 访问 JSON 值,
NSManagedObjectContext *context = [[DataAccessLayer sharedInstance] managedObjectContext];
NSArray *existingResults = [context fetchObjectsForEntityName:NSStringFromClass([Serchtrial class]) withSortColumn:nil withSortDescending:FALSE withPredicate:nil];
NSLog(@"->%@",existingResults);
Serchtrial *result;
for(int i=0;i<[existingResults count];i++)
{
result=[existingResults objectAtIndex:i];
[mydata setValue:result forKey:[NSString stringWithFormat:@"checka%d",i]];
}
NSLog(@"mydata age%@",[mydata objectForKey:@"checka0"]);
日志返回结果如下
mydata age<Serchtrial: 0x8c80a10> (entity: Serchtrial; id: 0x8c81990 <x- coredata://39E99C99-5639-4C67-86D5-D9B97C79EDF2/Serchtrial/p2> ; data: {
age = "18-25";
gender = Female;
keywords = "AB-ve,o+ve";
"trial_Id" = 0;
"trial_desc" = nil;
})
但我只想要单个字典中的数据
data: {
age = "18-25";
gender = Female;
keywords = "AB-ve,o+ve";
"trial_Id" = 0;
"trial_desc" = nil;
}
我应该对我的代码进行什么更改,请帮助解决这个问题。