Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective C --- Array is readable in a (void) function but not an (IBAction)
    text
    copied!<p>Hey all, I have an array that holds all of the .aif file paths in my app, which I found by using mainBundle and resources.</p> <p>This array needs to be passed down through 2 view controllers to reach where it is actually used. The problem is, it either crashes or logs something totally wrong. When I debug I get an EXC_BAD_ACCESS note at the crash, but not when I run it normally where it just crashes.</p> <p>Here's the place where it works;</p> <pre><code>- (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); } </code></pre> <p>That returns a long list of paths that end in fileName.aif. You get the idea.</p> <p>However...</p> <pre><code>// 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]; } </code></pre> <p>That snippet causes a crash. If I comment out the parts where it deals with possDrumSounds, it works fine. Otherwise it crashes or somehow changes the array to contain random objects like UIViewControllers that I have no idea where they came from.</p> <p>All help appreciated, thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload