On Saturday, February 1, 2003, at 09:51 PM, Rich Morin wrote:
Right, but since it's not a named pipe, I can do it all in-proc. i.e., I can open, write to, and close the tmp file before calling NSText to read it.At 6:47 PM -0500 2/1/03, Dan Mills wrote:My next step will be to make temporary rtf files at run time.Sounds reasonable, but there's a caveat. You don't want to allow a "race condition" between the writing and reading processes; if the reader outruns the writer, it'll see a premature EOF.
However, if I were still forking, it could use waitpid() to do avoid the race condition. Or, as you say, moving a file and polling on the other process (though if you have the pid, waitpid is better).
My problems have now shifted to RTF being just awful when it comes to utf8-encoded text (as far as I can see, anyway).
Do these just serialize the array/hash to disk atomically? And, how do I use them with CB?I think you might want to look at these instance methods:writeToFile:atomically writeToURL:atomically under the Foundation's NSArray and NSDictionary classes.
Thanks,
-Dan