• 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
Append to file with NSString writeToFile:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Append to file with NSString writeToFile:


  • Subject: Append to file with NSString writeToFile:
  • From: <email@hidden>
  • Date: Mon, 28 Feb 2005 7:06:12 +0000

In my application, I have an NSTask run a program to process some files.  The process will spit out some information that I'm trapping using NSPipe and NSFileHandle (for reading).  All of this is working fine.  I basically have a method that takes an array of file names (absolute paths here).  Each run through the loop launches the task with the appropriate switches and filenames, and produces output.

The problem I'm running into is for every file's output that is produced, I want to write it to a file.  So what I'm doing is creating an NSString from the NSData object returned by readDataToEndOfFile: from my NSFileHandle.  I do some string manipulation to tag on some info at the beginning of the string (filename, actually), and then I write it to file:

[fingerpring writeToFile:filePath atomically:YES];

This works for the most part, but after the loop is done processing all the files, I open the file only to see the last file's output.  So it's obvious that each write action is overwriting the contents.

How can I have it simply append the new information to the file, not write over what's already there?  Thanks.

James

 _______________________________________________
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

  • Follow-Ups:
    • Re: Append to file with NSString writeToFile:
      • From: Magnus Strand <email@hidden>
  • Prev by Date: key command mapping?
  • Next by Date: Re: Append to file with NSString writeToFile:
  • Previous by thread: key command mapping?
  • Next by thread: Re: Append to file with NSString writeToFile:
  • Index(es):
    • Date
    • Thread