[Pyobjc-dev] In and out of NSData
Brought to you by:
ronaldoussoren
From: Bob I. <bo...@re...> - 2003-01-07 01:03:18
|
I was just toying around with pyobjc today and I ran across a few stumbling blocks.. the NSString <-> str bridge doesn't work for raw data (stuff with characters > 128). Which is ok, because you can get around it with something like this (took me a few minutes of wandering the list archives): from Foundation import * import array s = '\xFF' b = array.array('B') b.fromstring(s) data = NSData.alloc().initWithBytes_length_(b, len(b)) print data Which is ok, and works fine. But how the heck do you do the opposite (short of writing to a tempfile)? I can get an ObjCPointer to mutableData or the like, but there aren't any useful methods in it because I can't use python to read data from a pointer (unless there's some sketchy stuff in objc that I haven't found yet). -bob |