: 그것은 내가 사용하는 경우 작동하지 않습니다 그러나AVAudioRecorder 특별한 경우에 기록되지 않습니다
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
date = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat: @"yyyy-MM-dd ss"];
NSString *dateWithString = [formatter stringFromDate:date];
NSLog(@"%@",dateWithString);
NSString *soundFilePath1 = [docsDir
stringByAppendingPathComponent:nil];
NSString *soundFilePath = [soundFilePath1
stringByAppendingPathComponent:@"sound.caf"];
NSLog(@"%@",soundFilePath);
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
NSError *error2;
self.recorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error2];
을 :
NSArray *dirPaths;
NSString *docsDir;
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = dirPaths[0];
date = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat: @"yyyy-MM-dd ss"];
NSString *dateWithString = [formatter stringFromDate:date];
NSLog(@"%@",dateWithString);
NSString *soundFilePath1 = [docsDir
stringByAppendingPathComponent:dateWithString];
NSString *soundFilePath = [soundFilePath1
stringByAppendingPathComponent:@"sound.caf"];
NSLog(@"%@",soundFilePath);
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:44100.0],
AVSampleRateKey,
nil];
NSError *error2;
self.recorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error2];
코드의 두 블록 사이의 차이는 다음
NSString *soundFilePath1 = [docsDir stringByAppendingPathComponent:dateWithString];
왜 이런 일이 발생합니까?