このコードを書くと、うまくいきます
NSString *recordFile = [NSTemporaryDirectory() stringByAppendingPathComponent: (NSString*)inRecordFile];
NSLog(@"////////////////////////// recordFile /////////////////////");
NSLog(recordFile) ;
url = CFURLCreateWithString(kCFAllocatorDefault, (CFStringRef)recordFile, NULL);
// create the audio file
XThrowIfError(AudioFileCreateWithURL(url, kAudioFileCAFType, &mRecordFormat, kAudioFileFlags_EraseFile,
&mRecordFile), "AudioFileCreateWithURL failed");
CFRelease(url);
しかし、recordFileをそのように変更すると
NSString* Dpath ;
NSArray * paths;
// Build the Directory
paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
Dpath = [paths objectAtIndex:0];
Dpath = [DICOMpath stringByAppendingPathComponent:@"YYYYYYYYYYYY"];
Dpath = [DICOMpath stringByAppendingPathComponent:[FirstDirectory stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]] ;
Dpath = [DICOMpath stringByAppendingPathComponent:[SecondtDirectory stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]];
Dpath = [DICOMpath stringByAppendingPathComponent:@"XXX"];
NSString *recordFile = [Dpath stringByAppendingPathComponent:inRecordFile];
コンソールに AudioFileCreateWithURL failed というメッセージが表示されます。コードの何が問題なのか、2 番目のコードで使用するパスが存在することを確認してください。inRecordFile は caf ファイル名です