Skip to content

Instantly share code, notes, and snippets.

@nickyp
Created February 29, 2012 07:52
Show Gist options
  • Save nickyp/1938968 to your computer and use it in GitHub Desktop.
Save nickyp/1938968 to your computer and use it in GitHub Desktop.
NSFileHandle seekToEndOfFile
NSFileHandle *aFileHandle;
NSString *aFile;
aFile = [NSString stringWithString:@"Your File Path"]; //setting the file to write to
aFile = [logFile stringByExpandingTildeInPath];
aFileHandle = [NSFileHandle fileHandleForWritingAtPath:aFile]; //telling aFilehandle what file write to
[aFileHandle truncateFileAtOffset:[aFileHandle seekToEndOfFile]]; //setting aFileHandle to write at the end of the file
[aFileHandle writeData:[toBeWritten dataUsingEncoding:nil]]; //actually write the data
For more Information see Documentation---Foundation---NSFileHandle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment