• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: creating files to write data to?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating files to write data to?


  • Subject: Re: creating files to write data to?
  • From: Ken Hawkins <email@hidden>
  • Date: Thu, 11 Mar 2004 18:21:00 -0800

thank you thank Ondra! i knew there had to be a better way!

this will do with some teaking of course. the process is assembling a file with tags (similar to jpeg format0 i might end up having to go with a Dictionary to hold the data but this is a prototype....

thanks again!
ken;
On Mar 11, 2004, at 3:37 PM, Ondra Cada wrote:

Ken,

On Thursday, Mar 11, 2004, at 23:51 Europe/Prague, Ken Hawkins wrote:

how can i create a 0 length file that i will throughout the processes of my app write data to. this is mixed string and binary data.

Do you insist on this workflow?

In a vast majority of cases you just write the complete file atomically, like

NSData *d=... the contents of file computed somehow ...
[d writeToFile:FILENAME atomically:YES];

Nevertheless, you can use NSFileHandle

NSString *fname=...;
[@"" writeToFile:fname atomically:NO]; // create the empty file
NSFileHandle *fh=[NSFileHandle fileHandleForWritingAtPath:fname];
...
[fh writeData:... partial contents of file computed somehow ...]; // as many times as you want to
...
[fh closeFile];
---
Ondra Hada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: creating files to write data to? (From: Ondra Cada <email@hidden>)

  • Prev by Date: Re: NSImageView drawing the NSImage...
  • Next by Date: Re: debugging a framework ?
  • Previous by thread: Re: creating files to write data to?
  • Next by thread: kqueue
  • Index(es):
    • Date
    • Thread