在这里,我得到了 fetchedObjects 中的值。如何更新数组中的值?
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Reserve" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
//NSSortDescriptor tells defines how to sort the fetched results
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"number" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
NSLog(@"sort count%d",[sortDescriptors count]);
fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(number = 100)", self.txtReserve.text];
// [fetchRequest setPredicate:predicate];
[fetchedResultsController.fetchRequest setPredicate:predicate];
self.fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
NSLog(@"Count of array::::%d",[fetchedObjects count]);
NSManagedObject *device = [fetchedObjects objectAtIndex:0];
NSLog(@"device::::%@",device);