このコードを使用して、セグエを介してデータを渡そうとしています:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"exerciseDetailDescription"]) {
SoulExerciseDetailQuarViewController *destination = segue.destinationViewController;
if ([destination respondsToSelector:@selector(setOverview:)]) {
NSDictionary *overview = @{@"name" : [_exercise objectForKey:@"name"], @"longDescription" : [_exercise objectForKey:@"longDescription"]};
[destination setValue:overview forKey:@"overview"];
}
}
else if ([segue.identifier isEqualToString:@"exerciseDetailGear"]) {
SoulExerciseDetailTriaViewController *destination = segue.destinationViewController;
if ([destination respondsToSelector:@selector(setSelectedGearString:)]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
NSString *selectedGearString = cell.detailTextLabel.text;
[destination setValue:selectedGearString forKey:@"selectedGearString"];
}
}
else if ([segue.identifier isEqualToString:@"exerciseDetailCategory"]) {
SoulExerciseDetailDuaViewController *destination = segue.destinationViewController;
if ([destination respondsToSelector:@selector(setSelectedCategoryString:)]) {
NSLog(@"Go");
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
NSString *selectedCategoryString = cell.detailTextLabel.text;
[destination setValue:selectedCategoryString forKey:@"selectedCategoryString"];
}
}}
したがって、セグエの宛先で見つかったセッターに応答すると、データの転送が許可されます。
奇妙なことに、最初のものは正しく応答しますが、2 番目と 3 番目では、宛先ビュー コントローラーがこれらのセッターに応答していないと表示されます。
たとえば、3 番目の例では、nslog は表示されません。