与选择另一个NSb中的NSArrayController进行绑定
|
我有两个笔尖:
Store.nib
Product.nib
Product.nib的文件所有者是
NSViewController
的子类,它具有一个属性ѭ1which,并绑定了各种控件:
@property(nonatomic, retain) SRProduct *product;
Store.nib有一个绑定到属性SRApplicationController
的to3ѭ对象:
@property(nonatomic, retain) NSArray *products;
SRApplicationController
到NSArrayController
物体有出口。
在-[SRApplicationController init]
方法中,我使用Product.nib笔尖初始化了一个SRProductController
对象。在ѭ10中,将产品控制器的视图添加到Store.nib中的视图,并将SRApplicationController
对象的productsArrayController
属性(出口)绑定到产品控制器的product
:
- (id)init {
if (self = [super init]) {
self.productController = [[SRProductController alloc] initWithNibName:@\"Product\" bundle:nil];
}
return self;
}
- (void)awakeFromNib {
[self.productView removeAllSubviews]; // this method is from a category
[self.productView addSubview:self.productController.view];
[self.productController.view setFrame:self.productView.bounds];
[self.productsArrayController bind:@\"selectedObjects\" toObject:self.productController withKeyPath:@\"product\" options:nil];
}
当我运行该应用程序时,没有任何错误,没有警告,控制台仍然为空,Store.nib中所有产品的表视图显示了所有产品,我可以选择它们。问题在于Product.nib中的所有字段均为空,但它们绑定到文件所有者的product
属性。谁能帮助我解决这个问题?提前致谢。 :)
没有找到相关结果
已邀请:
2 个回复
裸雷胜檀哭
(它可能实际上是
忘记了我的脑袋)。您还可以以相同方式绑定选择索引。这将使明细笔尖中的阵列控制器能够跟上明细笔尖中发生的事情,之后,您只需像平常一样绑定每个明细元素即可(即,产品名称文本字段的值绑定为18)。 如果您忘记将详细信息笔尖的数组控制器的排序描述符绑定到列表笔尖中与其对应的数组描述符,则详细信息笔尖将在列表中的每次选择更改时更新,但可能不会更改为正确的产品(绑定只是通过selectionIndex而不是选择了什么对象)。
坝胺绣敝