这是我想从中获取价值的数组示例。
coursesArray = [[NSMutableArray alloc]init];
// AR111:
[coursesArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:
@"MUR",@"courseType",
@"AR111",@"courseCode",
@"Arabic Communication Skills (I)",@"courseName",
@"3",@"creditHours",
@"",@"preRequisites",
@"63.000",@"coursePrice",
@"6.000",@"courseEPP",
@"This course aims at .",@"courseDetails",
nil]];
这是我获得价值的代码。
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];
int i = 0;
for (i = 0; i < [coursesArray count] ; i++) {
NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
[newManagedObject setValue:[[coursesArray objectAtIndex: i ]forKey:@"courseName"] forKey:@"courseName"];
}
如果有人可以帮助我更正以下部分:
[newManagedObject setValue:[[coursesArray objectAtIndex: i ]forKey:@"courseName"] forKey:@"courseName"];
这些值将添加到核心数据 forKey:@"courseName"。