Cocoa绑定问题;绑定表列不显示任何数据,控制台中没有错误 [英] Cocoa bindings problem; bound table columns don't show any data, no errors in console

查看:174
本文介绍了Cocoa绑定问题;绑定表列不显示任何数据,控制台中没有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将我的Cocoa项目从手动同步的界面模型转换为绑定模型,因此我不必担心界面粘合代码。

I'm having trouble converting my Cocoa project from a manually-synched interface model to a bindings model so that I don't have to worry about interface glue code.

我按照CocoaDevCentral Cocoa Bindings教程来确保我已涵盖所有基础,但事情不能正常工作。我有一个主 - 细节的接口,但我有麻烦,甚至让主接口部分正常工作。在主列中没有显示任何数据,即使我已经设置了类似于本教程中显示的绑定模型。我确保所有的控制器和对象有 - (id)键 - (void)setKey:(id)key 方法,使它们符合绑定,我在我的nib中创建一个ControllerAlias对象,将它连接到我的控制器,创建一个NSArrayController绑定到ControllerAlias连接到的类的NSMutableArrays之一,确保设置数组中包含的对象类型,然后我将一个表列绑定到NSArrayController。

I followed the CocoaDevCentral Cocoa Bindings tutorial to make sure that I had covered all the bases, but things aren't working correctly. I have a master-detail interface, but I'm having trouble even getting the master portion of the interface to work correctly. No data is showing up in the master column, even though I've set up the bindings model similar to how it is shown in the tutorial. I've made sure all my controllers and objects have -(id)key and -(void)setKey:(id)key methods so that they're bindings-compliant, I've created a ControllerAlias object in my nib, connected it to my controller, created an NSArrayController that binds to one of the NSMutableArrays from the class that ControllerAlias connects to, made sure to set the type of objects that are contained within the array, and then I've bound a table column to the NSArrayController.

我没有得到任何错误控制台,并将 NSBindingDebugLogLevel 设置为1也不会产生任何错误,这将有助于我弄清楚问题是什么。

I'm getting no errors whatsoever in the Console, and setting NSBindingDebugLogLevel to 1 doesn't produce any errors either, that would help me figure out what the problem is.

我可以想到的唯一的其他事情,以确保事情是否正确工作是检查NSMutableArray连接到NSArrayController实际上有其中的东西,它是。

The only other thing I could think of to make sure that things are working correctly is to check that the NSMutableArray that connects to the NSArrayController actually has something in it, and it does.

有任何建议吗?

推荐答案

在你的key:方法中添加了一个断点确定它是否被调用?如果不是,那么这将表明对于表列中的绑定,没有正确设置某些内容(因为您已经验证了您的数组中有项目)。

Have you put a breakpoint in your key: method to determine if it is getting called or not? If it isn't, then that would indicate that something isn't set up correctly for the binding in the table column (since you have verified that your array does have items in it).

我不认为你需要创建一个对象控制器了(该教程是有点过时)。只需在您的NIB中创建一个对象,并将其类设置为您的Controller类。您可以直接通过它而不是ObjectController来设置绑定。

I don't think that you need to create an Object Controller anymore (that tutorial is a bit out of date). Just create an Object in your NIB, and set its class to your Controller class. You can set up the bindings directly through it instead of the ObjectController.

要设置绑定,我执行以下操作:

To set up a binding, I do the following:


  1. 在NIB中创建我的控制器实例。

  2. 创建NSArrayController,将其绑定到控制器中的数组。
  3. 对于表中的每个列,将值绑定到数组控制器中的对象的成员。

这应该是你需要做的 - 我认为他们已经清理了很多,因为绑定是在几个版本前首次引入。

That should be all that you need to do - I think they've cleaned this up quite a bit since bindings were first introduced a few versions ago.

这篇关于Cocoa绑定问题;绑定表列不显示任何数据,控制台中没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆