gpt4 book ai didi

ios - 从表中传递选定的行以准备 segue Objective C

转载 作者:行者123 更新时间:2023-11-28 21:32:15 24 4
gpt4 key购买 nike

我如何将这一行传递给我的 prepare for segue 方法?

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [self.secondsTable cellForRowAtIndexPath:indexPath];
[[self.pickerData objectAtIndex:indexPath.row] intValue];
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.destinationViewController isKindOfClass:[MyViewController class]]) {
MyViewController * dvc = (MyViewController*)segue.destinationViewController;
NSInteger row = [self.timePicker selectedRowInComponent:0];
dvc.seconds =[[self.pickerData objectAtIndex:row] intValue];
}
}

我之前有一个时间选择器并将其转换为表格,所以我的代码中仍然有 NSInteger row = [self.timePicker selectedRowInComponent:0]; 我怎样才能成功地从我的表格 View 进入我的 prepare fro segue 方法。

我试过这样通过它但没有运气:- 我崩溃了

NSInteger row = [self.pickerData objectAtIndex:[[self.secondsTable indexPathForSelectedRow] row]];
dvc.seconds =[[self.pickerData objectAtIndex:row] intValue];

请帮忙

最佳答案

您正试图将对象设置为 NSInteger,即代码中的行让我修改你的代码

NSInteger row1 = [[self.secondsTable indexPathForSelectedRow] row];// Get row value
NSInteger row = [self.pickerData objectAtIndex:row1];// Error line
dvc.seconds =[[self.pickerData objectAtIndex:row] intValue];// Use to have object

这就是你正在做的。

更改代码:

NSInteger row = [self.pickerData objectAtIndex:[[self.secondsTable indexPathForSelectedRow] row]];
dvc.seconds =[[self.pickerData objectAtIndex:row] intValue];

收件人:

dvc.seconds = [[self.pickerData objectAtIndex:[[self.secondsTable indexPathForSelectedRow] row] intValue];

NSInteger row = [[self.secondsTable indexPathForSelectedRow] row];// Get row value
dvc.seconds =[[self.pickerData objectAtIndex:row] intValue];// Use to have object

关于ios - 从表中传递选定的行以准备 segue Objective C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35433439/

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