KVC & subcriptable objects Re: [Pyobjc-dev] NSUserDefaultsController
Brought to you by:
ronaldoussoren
From: b.bum <bb...@ma...> - 2004-04-12 23:45:16
|
On Apr 12, 2004, at 4:21 PM, Paul Donovan wrote: > <_NSControllerObjectProxy: 0x1123830> > 2004-04-13 00:12:22.453 Test[19056] An exception has occured: > Traceback (most recent call last): > File > "/Users/pauld/Projects/Test/build/Test.app/Contents/Resources/ > __main__.py", line 18, in ? > AppHelper.runEventLoop(argv=[]) > File > "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ > python2.3/site-packages/PyObjC/PyObjCTools/AppHelper.py", line 71, in > runEventLoop > NSApplicationMain(argv) > File > "/Users/pauld/Projects/Test/build/Test.app/Contents/Resources/ > RatingsModel.py", line 46, in awakeFromNib > self.makeLibrary(file) > File > "/Users/pauld/Projects/Test/build/Test.app/Contents/Resources/ > RatingsModel.py", line 29, in makeLibrary > print prefs['FontName'] > TypeError: unsubscriptable object > > I'm not sure why the type of 'prefs' is an NSControllerObjectProxy. I > was expecting it to be an NSDictionary* (and hence a python > dictionary). I have an instance of an NSUserDefaultsController in my > nib file, so I'm a bit stuck at this point. It is an NSCOP because it is not a static dictionary of values. It is literally a proxy to the NSUserDefaultsController. This raises a slightly different issue -- one that we have sort of punted on for a while. Since KVC -- key/value coding -- is implemented on NSObject [both -valueForKey: and -setValue:forKey:] is there any reason to not support subscript style access to all Obj-C objects passed to the python side of the bridge? It is a trivial change to make it so, I believe. b.bum |