Mar
30
Day 32: NSMenuItem actions - Don’t do it like this
Yesterday’s article reminded me of a clear mistake I made when I first started with Cocoa programming. The problem concerned connecting menu items to particular actions in my document. With a document-based application this was a problem since both were not in the same nib file. What I ended up doing was connecting them to my AppController in the MainMenu.nib and in the AppController forwarding them to the current document. Keep in mind I didn’t know anything then about NSResponder and the responder chain. The tip of the day is an obvious one; don’t do this. Use the responder chain instead. Tomorrow I continue with explaining the route I take nowadays and I hope you’ll find it instructive and a better way than the one described above.