gpt4 book ai didi

iphone - 准备继续传递数据选择器

转载 作者:行者123 更新时间:2023-11-29 04:06:59 27 4
gpt4 key购买 nike

我正在尝试使用以下代码通过 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 目标中找到的 setter,则它允许传输数据。

奇怪的是,第一个响应正确,但在第二个和第三个中,它说目标 View Controller 没有响应那些 setter

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

最佳答案

之前评论的回答:

NSLog 目标类:

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

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

OP:“它说导航 Controller ”

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

关于iphone - 准备继续传递数据选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15035462/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com