IBOutlet properties must be readwrite… mostly

I couldn’t for the life of me figure out why two out of three IBOutlet-connected properties were being connected just fine, but a third wasn’t.  What was different?  Long story short:

  • One was “(weak)”, meaning implicitly readwrite.  Apparently when I added that one I got it right accidentally.
  • One was “(weak, readonly)” and yet still worked.  The reason, it turns out, is that it was just a redeclaration of a superclass’s property, so apparently whatever check is used when connecting outlets is something along the lines of respondsToSelector(setFoo:).  Which makes perfect sense, but leads to this awkward situation.
  • The third was then added as a copy-paste-tweak of the second one, but alas wasn’t redeclaring a subclass’s property.

It took me an annoyingly long time to figure it out, especially since there’s no exceptions thrown, no log messages, nothing.  Thank a lot AppKit.

Leave a Comment