• 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: NSData writeToFile
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData writeToFile


  • Subject: Re: NSData writeToFile
  • From: Clark Cox <email@hidden>
  • Date: Thu, 23 Dec 2004 19:52:48 -0500

On Thu, 23 Dec 2004 15:38:32 -0800, Chuck Soper <email@hidden> wrote:
> Hello,
>
> I'm using this NSData's method:
>    - (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag
> to write some data to a file on disk. It works great.
>
> If a file with the same name already exists, writeToFile: just
> replaces it. Is this expected behavior? Is this approach okay? Do you
> think that it could break in the future?

This appears to be the intended behavior. Otherwise, the "atomically:"
parameter would be pointless.

>
> Should I see if the file exists and delete if it does with these
> FileManager methods?
> - (BOOL)fileExistsAtPath:(NSString *)path
> - (BOOL)removeFileAtPath:(NSString *)path handler:(id)handler

This would prevent your write from being atomic (what happens if the
remove succeeds, but some error happens during the write; you've then
got a potentially partially written file).


--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: One delegate's method doesn't work
  • Next by Date: Re: Examining the Call Stack
  • Previous by thread: NSData writeToFile
  • Next by thread: Is drawRect really where setShowsFirstResponder should be called?
  • Index(es):
    • Date
    • Thread