문제

I'd like write a file to disk using multiple NSOutputStreams (each one in a different thread). I know how to handle the threading issue, but I can't figure out what to use to write different byte-ranges to a single file at the same time.

For example, say the target file will be 100 MB on disk when the write process is complete. I have 4 threads with 4 streams (we'll call them s0, s1, s2, and s3) that want to write 25MB to the target file. I want each stream (s0-3) to be able to write at the same time to their respective target byte ranges (e.g. s0 writes from 0MB-25MB, s1 from 25MB-50MB, etc.). Each stream is independent, so I can tell which stream will receive bytes or when.

Thanks.

도움이 되었습니까?

해결책

Use NSFileHandle and its -seekToFileOffset: method.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top