Ok so I have this method (found here). It appends 2 wav files together to play them afterwards. The method gets called like this:
if(soundFileURL != nil) {
NSURL *tempURL = [WavUtils mergeFile1:finalSoundFileURL withFile2:soundFileURL];
if(tempURL != nil) {
NSLog(@"Wav files have been merged: %@", [tempURL absoluteString]);
finalSoundFileURL = [tempURL retain];
[soundFileURL release];
soundFileURL = nil;
[recorder release];
recorder = nil;
} else {
NSLog(@"Wav files could not be merged.");
}
}
The retain in finalSoundFileURL = [tempURL retain]; has been replaced with many other things than retain but it doesn’t work at all. When the merging is done i check what the file contains with this:
NSLog(@"Calculated: %d - Real: %d", totalLength, [soundFileData length]);
NSLog(@"From file: %d", [[NSData dataWithContentsOfURL:file1] length]);
This shows the following in the log:
2012-01-02 18:20:28.549 App[2186:207] Calculated: 72146 - Real: 72146
2012-01-02 18:20:28.549 App[2186:207] From file: 72146
So the file is filled, the NSURL is filled and points to the correct file. But when i try to send this file to the server i check again with this:
NSLog(@"Adding file: %@ with length: %d", [finalSoundFileURL absoluteString], [[NSData dataWithContentsOfURL:finalSoundFileURL] length]);
But this returns the following:
2012-01-02 18:22:38.980 App[2186:207] Adding file: (null) with length: 0
This leads me to beleve it’s an autorelease problem, but I can’t find it! If anyone has any idea where it could be, please tell me.
Regards
Sorry for not posting this sooner but the problem was a bad release/autorelease call on the variable before it was sent to the method described in the question. I found it by following the variable from start to end and check what it’s doing and what happens to it.