I´m trying to store some data in a file. I open the file the first iteration, and add the info. But, when the algorithm end, file size is 5kbs, it must be like 2,5 Mbs.
if (!isopen)
{
NSArray *paths;
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
// Check DD
if ([paths count] > 0)
{
NSLog(@"Found a path");
fichero2 = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"out2.raw"];
NSLog(@"path %@",fichero2);
} else {
//d'oh, something went really wrong
NSLog(@"ERROR: could not open %s\n", "out.raw");
return -1;
}
isopen = 1;
}
else
{
// Write file
NSMutableData *data = [NSMutableData dataWithLength:1152*2];
[data appendBytes:((SInt16 *)[audioProcessor audioBuffer].mData) length:1152*2];
[data writeToFile:fichero2 atomically:YES];
}
Is really need to close the file? It auto close itself? So, why data is not stored?
I think you are creating a new NSData each loop,
Should be outside the dope of the iteration, no?
then for