Re: [Pyobjc-dev] Using C Datatypes
Brought to you by:
ronaldoussoren
From: Ronald O. <ron...@ma...> - 2009-10-11 11:04:11
|
On 10 Oct, 2009, at 1:42, Jan-Hendrik Hanne wrote: > Hi Ronald, > > Ronald Oussoren schrieb: >> - how does it not work? >> - and on which os-release? > > I am using the Iphone, this might be the problem. I don't support PyObjC on iPhone and won't do so until there is a way to run python code on the iPhone without breaking the SDK rules. > > This is my code: > > self.stream=NSOutputStream.alloc().initToFileAtPath_append_ > (self.pathToFile,YES) > self.stream.open() > > Works great so far. Empty file is created. > > stream.write_maxLength_("test",4) > App crashes here > This works fine with the current trunk on OSX 10.6: >>> from Foundation import NSOutputStream >>> s = NSOutputStream.alloc().initToFileAtPath_append_('/tmp/ log.txt', False) >>> s.open() >>> s.write_maxLength_('test', 4) 4 >>> s.close() The file then contains the bytes I wrote to it. >> - which version of pyobjc are you using? > > 1946-3 I have no idea what this version number means, this might be some internal version code for the iPhone port. Please ask the developer of the iPhone port to investigate, this seems to be a problem in that port. Ronald > > Jan > >> Ronald >> On 9 okt 2009, at 20:04, Jan-Hendrik Hanne <j-h...@tu...> >> wrote: >>> Hi! >>> >>> Ronald Oussoren wrote: >>>> On Friday, October 09, 2009, at 04:53PM, "Jan-Hendrik Hanne" <j-h...@tu... >>>> > wrote: >>>>> Hi! >>>>> >>>>> Maybe this question was answered before, but I couldn't find it >>>>> in the archive. >>>>> How can I use C data types in Python? >>>>> Concrete: I want to use >>>>> - (NSInteger)write:(const uint8_t *)buffer maxLength:(NSUInteger) >>>>> length >>>>> of the NSOutputStream class. >>>>> How can I create the buffer? >>>> The buffer should be a python string, or another type that >>>> implements the buffer protocol (an array.array of bytes should >>>> therefore also work). >>>> That is: >>>> aStream.write_maxLength_("hello world", 10) >>> >>> Thank you for your fast answer. Unfortunately, it doesn't work >>> with a string. I decided to write the file in the python way. >>> Hopefully it is fast enough. >>> >>> Jan >>> >>>> Ronald >>>>> Thanks >>>>> Jan >>>>> >>>>> ------------------------------------------------------------------------------ >>>>> Come build with us! The BlackBerry(R) Developer Conference in >>>>> SF, CA >>>>> is the only developer event you need to attend this year. >>>>> Jumpstart your >>>>> developing skills, take BlackBerry mobile applications to market >>>>> and stay ahead of the curve. Join us from November 9 - 12, 2009. >>>>> Register now! >>>>> http://p.sf.net/sfu/devconference >>>>> _______________________________________________ >>>>> Pyobjc-dev mailing list >>>>> Pyo...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev >>>>> >>>>> >>> > > -- > Jan-Hendrik Hanne > Mittelweg 94 > 38106 Braunschweig > Tel: 0531/2889855 |