I want to use NSOutputStream to accumulate data, and then, when done, create an NSData object with the contents. I can do this when the output stream is file based, as follows:
NSString *tmpDirectory = NSTemporaryDirectory(); NSString *filePath = [tmpDirectory stringByAppendingPathComponent:@"tempfile"]; [[NSFileManager defaultManager] createFileAtPath:filePath contents:nil attributes:nil]; NSOutputStream *outputStream = [[NSOutputStream alloc] initToFileAtPath:filePath append:NO]; [outputStream open];
I want the 'contents' variable to populate without creating a temp file. Can I do all this in my memory? I do not see the API for this in the NSOutputStream documentation.
source share