通过 didSelectRow UIPickerView 传递托管对象数据

发布于 2024-11-17 21:53:42 字数 796 浏览 8 评论 0原文

我对如何通过 didSelectRow UIPickerView 操作传递获取的托管对象数据有点迷失。

在上一个视图中,我像这样传递了 CalcInfo 对象:

CalcInfo *calc = (CalcInfo *)[_calcInfos objectAtIndex:indexPath.row];
self.myPageOneViewController.calcInfos = calc;

我成功地将 calcInfos.attribute 用于所有 IBAction:(id)sender 按钮,但 pickerView 无法获取/使用数据。 updateLabel 操作始终将 calcInfos.attribute 设为 NULL。这是我的一些代码

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
[self updateLabel];

}

- (void)updateLabel {

double stdrate = [calcInfos.infusionstd doubleValue];
double lowrate = [calcInfos.infusionlow doubleValue];

if (calcInfos.infusionlow == NULL) {
    NSLog(@"It's null");
}

}

非常感谢您的帮助!

I'm a bit lost on how to pass my fetched managed object data through a didSelectRow UIPickerView action.

On the previous view, I passed the CalcInfo object like this:

CalcInfo *calc = (CalcInfo *)[_calcInfos objectAtIndex:indexPath.row];
self.myPageOneViewController.calcInfos = calc;

I was successfully able to use calcInfos.attribute for all my IBAction:(id)sender buttons, but the pickerView isn't able to fetch / use the data. The updateLabel action always has calcInfos.attribute as NULL. Here's a bit of my code

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
[self updateLabel];

}

- (void)updateLabel {

double stdrate = [calcInfos.infusionstd doubleValue];
double lowrate = [calcInfos.infusionlow doubleValue];

if (calcInfos.infusionlow == NULL) {
    NSLog(@"It's null");
}

}

Your help is much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

豆芽 2024-11-24 21:53:42

选择器视图是一个具有自己的硬连线控制器的子视图。它返回在其委托消息“didSelectRow:inComponent”中选取的行和列/组件。

您需要将该信息传递给您的 updateLabel 方法,以便您可以将 pickerview 选择与您的托管对象相关联。目前,该方法根本不执行任何操作。

The picker view is a subview with its own hardwired controller. It returns the row and column/component picked in its delegate message `didSelectRow:inComponent'.

You need to pass that info along to your updateLabel method so that you can relate the pickerview selection to your managed objects. Right now, the method does nothing at all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文