Re: [Pyobjc-dev] problem saving as rtfd
Brought to you by:
ronaldoussoren
From: Marcel W. <ma...@me...> - 2003-05-12 06:43:53
|
> plaintext = "" > cyphertext = NSData.alloc() Minor nit: you shouldn't really have a partly initialized instance flying around. > #if the plaintext was manually encrypted then > it needs no further encryption > #in fact further encryption could be harmful > if self.encrypted == NO and > self.saveSwitch.state() == 1: > #edited out as this code isn't running > #at this time. > else: > length = len(self.text.string()) > > cyphertext.initWithBytes_length(self.text.RTFDFromRange_((0,length)),le > ngth) That's the problem right here: 1. RTFDFromRange already returns an NSData, and what you are doing is initializing a second NSData object with the pointer of the NSData *object*. 2. RTFDFromRange is "an RTFD stream corresponding to the characters and attributes within aRange". This is a pasteboard representation an not something you can directly/usefully save as a file. So, what you need is -RTFDFileWrapperFromRange:documentAttributes: , which returns a file-wrapper object that you can save. More can be found in the fine documentation: NSAttributedString class reference + some concept docs "RTF Files and Attributed Strings", referenced from the NSAttributedString class reference. Marcel -- Marcel Weiher Metaobject Software Technologies ma...@me... www.metaobject.com Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc. |