大家好,我有一个数组,其中包含我的应用程序中的所有 .aif 文件路径,这是我通过使用 mainBundle 和资源找到的。
该数组需要通过 2 个视图控制器向下传递才能到达实际使用的位置。问题是,它要么崩溃,要么记录完全错误的东西。当我调试时,我在崩溃时得到一个 EXC_BAD_ACCESS 注释,但当我正常运行它时,它只是崩溃了。
这是它工作的地方;
- (void)buildDrumTrigger {
defaultSounds = [[NSArray alloc] initWithObjects: @"kick_3", @"aif", @"snare_1", @"aif", @"HiHat_1", @"aif", @"ride_1", @"aif", @"crash_1", @"aif", @"crash_2", @"aif", @"crash_3", @"aif", @"wave_1", @"aif", nil];
self.DrumObject = [[DrumTrigger alloc] initWithSounds:defaultSounds:5:volumeBox];
[defaultSounds release];
NSLog(@"Possible Sounds: %@", DrumObject.possDrumSounds);
}
这将返回以 fileName.aif 结尾的一长串路径。你明白了。
然而...
// Change the current view to the options window.
- (IBAction)goToOptionsView {
NSLog(@"Loading options menu");
NSLog(@"DrumObject.drumSounds: %@", DrumObject.drumSounds);
NSLog(@"DrumObject.possDrumSounds: %@", DrumObject.possDrumSounds);
optionsViewController.soundBox2 = DrumObject.drumSounds;
optionsViewController.possDrumSounds = DrumObject.possDrumSounds;
[self presentModalViewController:optionsViewController animated:YES];
}
该片段导致崩溃。如果我注释掉它处理 possDrumSounds 的部分,它工作正常。否则它会崩溃或以某种方式更改数组以包含像 UIViewControllers 这样的随机对象,我不知道它们来自哪里。
感谢所有帮助,谢谢!