目前正在处理核心数据,
下面是我的数据模型:
WorkoutType (One to Many workouts with WorkoutSet)
WorkoutSet (One to Many days with WorkoutDay)
WorkoutDay (One to Many exercises with WorkoutExercise
WorkoutExercise
所有 4 个数据都通过 4 个表格视图显示。
我正在使用 FetchedResultsController 并且一切正常。
我的下一个问题是我从锻炼锻炼表视图控制器传递到另一个视图控制器并徘徊我如何将所有数据传递到这个视图控制器。例如,我需要访问通过选择来访问锻炼锻炼数据的锻炼类型、锻炼设置和锻炼日数据。
下面是我的 WorkoutExerciseTableViewController 中的 fetchedResultsController:
-(void)fetchWorkoutExercises
{
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"WorkoutExercise"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"workoutDay = %@", self.workoutDay];
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"exerciseName" ascending:YES];
[fetchRequest setSortDescriptors:@[sortDescriptor]];
[fetchRequest setPredicate:predicate];
self.fetchedResultsController = [[NSFetchedResultsController alloc]
initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext
sectionNameKeyPath:nil cacheName:nil];
//self.fetchedResultsController.delegate = self;
NSError *error;
if (![self.fetchedResultsController performFetch:&error])
{
NSLog(@"Fetch failed: %@", error);
}
}
提前感谢您的帮助:)