On Jun 17, 2011, at 11:43 PM, Dave DeLong wrote:

> Hey List,
> 
> I'm writing a little app for myself to take a database full of text and 
> format it into either a Word Document or an RTF document (either one is fine 
> for my purposes).  I've got it working for small datasets, but I'm running in 
> to performance issues when trying to generate files larger than a couple of 
> megabytes.
> 
> Ideally, I'd like to create my thousands and thousands of 
> NSAttributedStrings, convert them to NSData objects, and stream them out to 
> disk.  Unfortunately, the APIs in AppKit require me to build a single 
> NSAttributedString and convert it into an NSData all at once; no streaming is 
> possible.  For my purposes, this is impractical because of the memory 
> implications of keeping tens of thousands of NSAttributedStrings alive for 
> the duration of the generation process.
> 
> The only thought I had to work around this was to generate my RTF data and 
> strip out the document-level attributes before streaming it out to disk.  
> Barring a superior solution, I'll end up doing this.
> 
> I surely can't be the first person to want to do  this, so I ask: what have I 
> missed?  How can I generate extremely large rich-text files without having to 
> build the entire file in memory before writing it out?

Have you considered breaking this file up into a series of smaller files 
instead? If the flie is sufficiently large that it is impractical to hold it 
all in memory while writing it, you may just end up causing problems for 
applications that load the entire file into memory while *reading* it (as, I 
believe, TextEdit does).

Charles_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to