通过 didSelectRow UIPickerView 传递托管对象数据
我对如何通过 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
选择器视图是一个具有自己的硬连线控制器的子视图。它返回在其委托消息“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.