Saturday, August 2, 2008

Cocoa Category in PyObjC

Continuing in the vein of "simple stuff about PyObjC," I thought I would show two examples of a Category. A Cocoa Category is what you do when you want to add new behavior to an existing class. That's contrasted with the situation that you want to change the behavior of an existing method in a class--- there you would use inheritance. This is explained in Apple docs. I found a nice example from Bob Ippolito (more detail here).

Here is a screenshot to show you the code with syntax coloring. (I've pasted in the commented Terminal output at various places).

No comments: