• 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: appending text to files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: appending text to files


  • Subject: Re: appending text to files
  • From: Markus Hitter <email@hidden>
  • Date: Sun, 20 Nov 2005 00:25:16 +0100


Am 19.11.2005 um 22:32 schrieb Robert Dell:

i need to append a NSMutableString to a file that already exists. is there any built-in method to do this?

i currently have this [...]

Is this actually failing? Or are you in seek of better performance?

One thing is, you don't have to read the file every time. It's sufficient to read it once at app startup, then write it as data changes. Unless you have multiple apps with simultanuouos (hello, spell checker?) write access, of course.

Another approach would be go to the roots of Obj-C, to C. A sequence of fopen(), fseek() and NSStrings's -dataUsingEncoding: in combination with fwrite() should do it. Don't forget fclose(), of course.

Third approach coming to mind would be to map the file into memory with NS(Mutable)Data's +dataWithContentsOfMappedFile, then append the string as data and release the NSData object.


The choice is your's.



Markus

- - - - - - - - - - - - - - - - - - -
Dipl. Ing. Markus Hitter
http://www.jump-ing.de/




_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: appending text to files
      • From: j o a r <email@hidden>
References: 
 >appending text to files (From: Robert Dell <email@hidden>)

  • Prev by Date: appending text to files
  • Next by Date: Re: appending text to files
  • Previous by thread: appending text to files
  • Next by thread: Re: appending text to files
  • Index(es):
    • Date
    • Thread