iOS / Objective-C App Delegates Explained Using Birds

As I build upon my understanding of Objective-C, I’ve been working to better understand the concept of a delegate and when they should be used.  In searching for clarity, I came upon an explanation by Mark Hernandez the administrator of

For posterity, I’ve copied Mark’s explanation here. For his full explanation and his code example, follow the link above.

My favorite way to explain how delegates work involves animals.

Let’s say you are going to create a particular bird. You start with a predefined class definition of a bird (provided in the existing framework as, say, CFBird). The existing framework class assumes all birds have certain things in common — they hatch and grow the same, poop the same, fly the same, and lay eggs the same way, etc. (tee hee, I said poop.  ) But different birds look different, are different sizes, chirp differently, eat different things, and may mate differently. Continue reading iOS / Objective-C App Delegates Explained Using Birds

Fix for Terminating App Due to Uncaught Exception 'NSInvalidArgumentException'

I’ve been experimenting with a multiview iPhone / iOS app with a tab-based navigation and came across an error and solution for “unrecognized selector sent to instance.”

In one of the tab’s views I had a standard button with a Touch Up Inside event that I had connected to a buttonClicked method in the view’s controller.  For some reason, when I tapped that button the app would crash.  This was not happening when I built the same stuff in a single view app.

I went searching and was happy to find that the problem was well described and solved in the developer forums of MacNN.  It turns out that when you have have multiple view controllers for separate .xib files being controlled by a Tab Bar Controller you need to take an extra step of setting the Class Identity for that particular view. Here’s how: Continue reading Fix for Terminating App Due to Uncaught Exception 'NSInvalidArgumentException'