[Pythonmac-SIG] strange behavior with NSArray and python unicode types
Jon Rosebaugh
chairos at gmail.com
Mon Aug 15 18:59:26 CEST 2005
On 8/14/05, Ronald Oussoren wrote:
>On 13-aug-2005, at 10:52, Jon Rosebaugh wrote:
>> You're right, it wasn't the problem; I'm kinda ashamed that I didn't
>> notice it now, because the self.Name was a unicode string too, and it
>> worked fine. Turns out that self.Data was a objc.pyobjc_unicode
>> object, since it had gone through the bridge and back. Sorry to
>> trouble you.
>
>That still sounds fishy. If I understand you correctly you have a
>pyobjc_unicode object that is not an empty string (that is
>"theString != ''"), but is an empty string when converted back to
>Objective-C. Could you elaborate on what you're doing? Unless the
>Objective-C strings is an NSMutableString and someone is mutating it
>behind your back the value in python should be the same as the value
>in ObjC.
Yeah. um. Basically, the pyobjc_unicode object is not an empty string.
(I get this object by calling editor.string(), where editor is a
NSTextView instance.) But when I try to feed it into a NSMutableArray
via addObject:, the resulting array has an empty string where the
pyobjc_unicode's contents should be.
However, if I feed unicode(self.Data) into the NSMutableArray, it
contains the string it should.
Moreover, when I create a tiny demo of the problem, it actually works
fine, which means I probably have crufty code somewhere. Hate it when
that happens.
More information about the Pythonmac-SIG
mailing list