This should get you on the right track. Mix and match pseudo code
Code:
-(void) concatFiles( NSString* path1, NSString* path2, NSString* combinedPath )
{
NSFileHandle * f1Handle = [NSFileHandle fileHandleForReadingAtPath: path1];
NSFileHandle *f2Handle = [NSFileHandle fielHandleForReadingAtPath: path2];
//might need to check if file exists first, if not create it using NSFileManager's createFileAtPath
NSFileHandle * combinedHandle = [NSFileHandle fileHandleForWritingAtPath: combinedPath];
// read data in small chunks to avoid hogging memory.
NSData* read = [f1Handle readDataOfLength: CHUNK_SIZE] ;
while( length of read != 0 )
{
[combineHandle writeData: read];
read = [f1Handle readDataOfLength: CHUNK_SIZE] ;
}
[f1Handle close];
//now do the same for f2Handle
//might need to ignore a few bytes in the front of file2 that isnt audio
[f2Handle readDataOfLength: HEADER_LENGTH];
NSData* read = [f2Handle readDataOfLength: CHUNK_SIZE] ;
while (... )
{
}
[f2Handle close];
[combineHandle close];
}