Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp on Objective C? My app keeps crashing?
    primarykey
    data
    text
    <p>I am creating an app for the Iphone/Itouch, but I keep on running into a couple of major leaks that just crash the app. In my game, right when I press play (from the home screen)It goes to another page that has the game on it. But, right after it appears, ind the console I get a Warning: Memory level=1. What could be happening? Here is my ViewDidLoad Method:</p> <pre><code>-(void)viewDidLoad { [super viewDidLoad]; array = [[NSMutableArray alloc] initWithCapacity:100]; bulletArray = [[NSMutableArray alloc] initWithCapacity:100]; pos = CGPointMake(0.0,-5.0); NSString *path = [[NSBundle mainBundle] pathForResource:@"GloriousMorning" ofType:@"mp3"]; AVAudioPlayer *theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; //float effects_Volume = [[NSUserDefaults standardUserDefaults] floatForKey:@"effectsVolume"]; //theAudio.volume = effects_Volume; [theAudio play]; </code></pre> <p>}</p> <p>And also, a second question, since my game is a shooting game, the user presses a button titled "Fire". But, every time I test my app on a device, It crashes when I press the fire button. Here is my code for the fire button. </p> <pre><code>-(IBAction)Fire { NSString *path = [[NSBundle mainBundle] pathForResource:@"gunShot" ofType:@"mp3"]; AVAudioPlayer *theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]; //float effects_Volume = [[NSUserDefaults standardUserDefaults] floatForKey:@"effectsVolume"]; //theAudio.volume = effects_Volume; [theAudio play]; //IBOutlet UIImageView *newBullet = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Bullet.png"]]; UIImageView *newBullet = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Bullet.png"]]; newBullet.frame = CGRectMake(0, 0, 10.0, 10.0); newBullet.center = CGPointMake(239.0, 236.0); [bulletArray addObject:newBullet]; [self.view addSubview:newBullet]; </code></pre> <p>}</p> <p>First, I create a sound. Then, I place a bullet right where the gun is currently located, and add it to an array so that every .01 of a second, in another bit of code, I can run through the array and check every bullet to detect collision.</p> <p>Please tell me what I am doing wrong. Thanks!!!</p> <p>The error when I click the Fire Button that makes the app crash is this: </p> <p>GDB: Data Formatters temporarily unavailable, will retry after a 'continue'(unknown error loading shared library "</p> <p>And Also I think I am making a huge leak when I try to play the audio, at least that's what someone told me. (If that is the case, please tell me how to fix it)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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