Re: [Pyobjc-dev] Problems with bindings
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2004-09-27 06:08:35
|
On 26-sep-04, at 21:41, Bob Ippolito wrote: > On Sep 26, 2004, at 3:13 PM, Bill Noon wrote: > >> I have a text field whose value is bound to an element of an >> ArrayController. >> >> This works fine when it is set up from a dictionary. However, when >> the field is edited, the bound dictionary gets a new key/value pair >> that are both NSCFString classes: >> >> before editing: >> 'Phones': [{'index': 0, 'Phone': u'(888) 123-4567', 'label': >> u'Work'}, >> {'index': 1, 'Phone': u'(888) 123-4567', 'label': >> u'Mobile'}, >> {'index': 2, 'Phone': u'(888) 123-4567', 'label': >> u'Home'}] >> >> after editing: >> 'Phones': [{<objective-c class NSCFString at 0xa01905f4>: >> <objective-c class NSCFString at 0xa01905f4>, >> 'Phone': u'(888) 123-4567', >> 'index': 0, >> 'label': u'Work'}, >> {'index': 1, 'Phone': u'(888) 123-4567', 'label': >> u'Mobile'}, >> {'index': 2, 'Phone': u'(888) 123-4567', 'label': >> u'Home'}] >> >> >> Is binding to python dictionaries working in pyobjc v1.1? This is >> running on OSX v10.3.5. > > Well the binding is obviously working.. However, my guess is that your > issue is caused by the fact that NSCFString hashes differently than > Python's unicode so they end up as different keys in the Python dict. > If you used a NSMutableDictionary instead, it should Just Work. The annoying part is that this should also work, but obviously doesn't. The NSCFStrings should have been converted to unicode objects before they got inserted into the dictionary... Ronald |