I have a XIB file with my controls in it, loaded in the Interface Builder (Xcode 4.0.2 on Snow Leopard).
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.
I’ve managed to link e.g. a button with an action in someClassController or someClass – and it works for both of them.
However, whenever I link an outlet to ANY of them, it fails to show up; and NSLog reports NULL pointers.
- 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.
To investigate this, add statements in the object’s initializer method(s) and possibly
awakeFromNibto log the value ofself.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.