1

首先,我什至无法让 .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-你的 iOS 应用程序/

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

4

0 回答 0