Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mingchen
Created August 21, 2012 08:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mingchen/3413361 to your computer and use it in GitHub Desktop.
Save mingchen/3413361 to your computer and use it in GitHub Desktop.
How to use NSOutputStream's outputStreamToFileAtPath
- (void)outputStreamToFileAtPathDemo
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *file = [documentsDirectory stringByAppendingPathComponent:@"foo.dat"];
NSLog(@"file: %@", file);
NSOutputStream *output = [NSOutputStream outputStreamToFileAtPath:file append:NO];
[output open];
//
//...
//
[output close];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment