使用AVAudioRecorder录制m4a,然后将该声音文件放入.plist文件中

时间:2013-01-17 22:00:24

标签: ios plist avfoundation avaudioplayer avaudiorecorder

首先,我甚至无法让.plist工作,因为我认为它应该在下面。我只是想写一个NSNumber并检索它

self.paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        self.documentsDirectory = [self.paths objectAtIndex:0];
        self.path = [self.documentsDirectory stringByAppendingPathComponent:@"data.plist"];
        self.fileManager = [NSFileManager defaultManager];
        NSError *error;
        if (![self.fileManager fileExistsAtPath:self.path]) {
            self.bundle = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];

            [self.fileManager copyItemAtPath:self.bundle toPath:self.documentsDirectory error:&error];

        }

        self.dataForDict = [[NSDictionary alloc] initWithContentsOfFile:self.documentSlashAudioPath];
        int value = 5;
        [self.dataForDict setValue:[NSNumber numberWithInt:value] forKey:@"value"];
        [self.dataForDict writeToFile:self.path atomically:YES];

        self.number = [self.dataForDict objectForKey:@"value"];
        NSLog(@"%i", [self.number intValue]);

最后一个NSLog应该给我5,但输出为0。

我正在尝试创建一个带有音频的.plist文件,以便与Sound Bank Player一起使用: http://www.hollance.com/2011/02/soundbankplayer-using-openal-to-play-musical-instruments-in-your-ios-app/

我知道如何录制声音并使用AVAudioRecorder和AVAudioPlayer播放,现在我只需连接点。

0 个答案:

没有答案