0

我正在尝试使用以下代码通过 segues 传递数据:

- (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"];

    }
}}

因此,如果它响应在 segue 的目的地中找到的设置器,则它允许传输数据。

奇怪的是第一个响应正确,但在第二个和第三个中,它说目标视图控制器没有响应那些设置器

例如,在第三个中没有显示 nslog。

4

1 回答 1

1

以前评论的回答:

NSLog 目标类:

NSLog(@"class name: %@", NSStringFromClass([destination class]));

我敢打赌,这门课不是你想的那样。

OP:“它说导航控制器”

这不是你所期望的,对吗?所以弄清楚为什么错误的东西被实例化了。

于 2013-02-23T01:36:08.533 回答