I’m having trouble with the
NSInvalidArgumentException nil string parameter when trying to use
AudioFileCreateWithURL
The problem is, fileURL prints to NSLog correct. I believe this is the correct format:
file://localhost/Users/me/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/1A617C0D-90CC-465C-9108-ECBCF85F075C/Documents/recording.wav
I’m guessing the __bridge conversion may be causing the problem.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString* docDir = [paths objectAtIndex:0];
NSString* file = [docDir stringByAppendingString:@"/recording.wav"];
NSURL *fileURL = [NSURL fileURLWithPath:file];
NSLog(@"%@", fileURL);
OSStatus audioErr = noErr;
audioErr = AudioFileCreateWithURL( (__bridge CFURLRef)fileURL, kAudioFileWAVEType, &asbd, kAudioFileFlags_EraseFile, &audioFile);
I am using ARC. I tried this as well:
audioErr = AudioFileCreateWithURL( (CFURLRef)CFBridgingRetain(fileURL), kAudioFileWAVEType, &asbd, kAudioFileFlags_EraseFile, &audioFile);
It caused the same exception.
Have you looked at http://lists.apple.com/archives/coreaudio-api/2010/Aug/msg00210.html? they used
CFStringRefto get it to work.