连接操作工作。连接插座不 [英] Connecting actions works. Connecting outlets doesn't
问题描述
我有一个 XIB
文件,其中我的控件,加载在Interface Builder(Xcode 4.0.2在雪豹)。
I have a XIB
file with my controls in it, loaded in the Interface Builder (Xcode 4.0.2 on Snow Leopard).
文件的所有者设置为 someClassController
类,我还在接口生成器中添加了一个NSObject实例 someClass
以及。
The file's owner is set to, let's say, the someClassController
class, and I've also added (in the Interface Builder) an NSObject instance of someClass
, as well.
但,每当我将一个插座链接到任何一个插件时,就会在someClassController或someClass中使用一个动作。他们,它没有出现;和 NSLog
报告 NULL
指针。
However, whenever I link an outlet to ANY of them, it fails to show up; and NSLog
reports NULL
pointers.
- 提示:我的问题在这里可能比看起来复杂得多,因为我的someClass和someClassController类继承其他类,继承其他类等等处理一个巨大到混乱的代码库,我真的不知道还有什么可能有帮助的post)...但是,我仍然想听听你的意见,在这种情况下可能会出错。 。
- Hint : My issue here could be much more complicated than it seems, since both my someClass and someClassController classes inherit other classes, which inherit other classes and so on (I'm dealing with a huge-to-chaotic codebase, and I don't really know what else could be helpful to post)... However, I would still like to hear your opinion on what might be going wrong in such a case...
推荐答案
当您看到类似的问题时,具有多于一个具有出口的类型的物体。
When you see problems like this, it's almost always because you have more than one object of the kind that has the outlet. The one in the nib whose outlet you connected is not the one that is examining its outlet.
要调查这一点,在对象的初始化方法中添加语句,并且可能 awakeFromNib
可记录 self
的值。
To investigate this, add statements in the object's initializer method(s) and possibly awakeFromNib
to log the value of self
.
(或者所有或者没有)对象可以在nib中创建,并且它们中的一些(或全部或者全部)可以在代码中创建;后面的组中的对象不会跳过 awakeFromNib
,因为他们没有。
Some (or all, or none) of the objects may be created in nibs, and some (or all, or none) of them may be created in code; objects in the latter group won't trip awakeFromNib
, since they didn't.
你已经把你的类的实例清单了,你可以杀掉它们,直到你留下你想要的。
Either way, once you've inventoried what instances of the class you have, you can kill them off until you're left with the ones you want.
这篇关于连接操作工作。连接插座不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!