Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adriantofan/e132462aaedb3deb3879 to your computer and use it in GitHub Desktop.
Save adriantofan/e132462aaedb3deb3879 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