我正在尝试将录制的音频文件保存在文档文件夹中。我试图用它CoreData
来保存录制的音频,但我无法弄清楚。集成它的最佳方法是什么?我的代码如下: -
if(_radio.isRecording) {
[_recordbutton setImage:[UIImage imageNamed:@"record_off.png"] forState:UIControlStateNormal];
[_radio stopRecording];
} else {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSString *recordname = [NSString stringWithFormat:@"%@%d.%@", [_detailItem objectForKey:@"name"], _recordingCounter++, [_radio fileExtensionHint]];
NSString *path = [documentsPath stringByAppendingPathComponent:recordname];
[_recordbutton setImage:[UIImage imageNamed:@"record_on.png"] forState:UIControlStateNormal];
[_radio startRecordingWithDestination:path];
}
}
- (void)radio:(MeroRadio *)radio didStopRecordingWithDestination:(NSString *)path {
NSLog(@"Did stop recording with destination: %@", path);
[_recordbutton setImage:[UIImage imageNamed:@"record_off.png"] forState:UIControlStateNormal];
NSURL *url = [NSURL fileURLWithPath:path];
[_recordings saveobject:[url lastpathcomponent];
}
_recordings
是一个NSMutableArray
。那么保存它的最佳方法是什么?