我有一个具有三个属性的实体“testData”:时间、节拍、速率。我需要每次都遍历“时间”属性,并将相应的节拍和速率值存储在 NSMutablearray 中。
NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];
NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
[newManagedObject setValue:[x] forKey:@"timeStamp"];
[newManagedObject setValue:[y] forKey:@"beat"];
[newManagedObject setValue:[z] forKey:@"rate"];
// Save the context.
NSError *error = nil;
if (![context save:&error]) {
// Replace this implementation with code to handle the error appropriately.
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();