Being a Mac OS X, Python and Cocoa fan, I decided to combine all three and try out PyObjC in Leopard. It's all built in so I found a tutorial on Apple Developer Connection that goes through a very simple app. The problem is it is outdated. Interface Builder and even XCode are updated and the screens are different.
I followed the tutorial as well as I could and ended up with the following error:
2007-12-15 00:23:53.175 pyave2[21268:10b] Unknown class `Averager' in nib file, using `NSObject' instead.
2007-12-15 00:23:53.203 pyave2[21268:10b] Cocoa Bindings: Error accessing value for key path numbersInput of object (from bound object with object ID 375 in Nib named MainMenu.nib): [ valueForUndefinedKey:]: this class is not key value coding-compliant for the key numbersInput.
2007-12-15 00:23:53.204 pyave2[21268:10b] Cocoa Bindings: Error accessing value for key path calculatedMedian of object (from bound object with object ID 383 in Nib named MainMenu.nib): [ valueForUndefinedKey:]: this class is not key value coding-compliant for the key calculatedMedian.
2007-12-15 00:23:53.205 pyave2[21268:10b] Cocoa Bindings: Error accessing value for key path calculatedMean of object (from bound object with object ID 381 in Nib named MainMenu.nib): [ valueForUndefinedKey:]: this class is not key value coding-compliant for the key calculatedMean.
Notice the Unknown class `Averager` in nib file?
That's our problem. The Python Class has not been imported. I opened up the generated *AppDelegate.py file and added the import and it worked!
Here's what my pyave2AppDelegate.py file looks like:
#
# pyave2AppDelegate.py
# pyave2
#
# Created by tbye on 12/12/07.
# Copyright __MyCompanyName__ 2007. All rights reserved.
#
from Foundation import *
from AppKit import *
import Averager
class pyave2AppDelegate(NSObject):
def applicationDidFinishLaunching_(self, sender):
NSLog("Application did finish launching.")
If there's enough interest I'll break out Skitch and completely rewrite an updated version of the this tutorial with XCode3 and the latest Interface Builder.