Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-14-2011, 05:31 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 35
Kenenth is on a distinguished road
Default App crashing on a device?

I am creating a shooter game. On the Iphone 4 Simulator , the app works just fine. On the actual device, All goes well, until I press the shoot button. Then the app crashes. Here is my code:

Code:
  
-(IBAction)Fire {
	
	NSString *path = [[NSBundle mainBundle] pathForResource:@"gunShot" ofType:@"mp3"];
	AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
	//theAudio.delegate = self;
	float effects_Volume = [[NSUserDefaults standardUserDefaults] floatForKey:@"effectsVolume"];
	theAudio.volume = effects_Volume;
	[theAudio play];
	

	
	IBOutlet UIImageView *newBullet = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Bullet1.png"]];
	newBullet.frame = CGRectMake(0, 0, 10.0, 10.0);
	newBullet.center = CGPointMake(239.0, 236.0);
    [bulletArray addObject:newBullet];
	[self.view addSubview:newBullet];
	[newBullet release];
	
	
	
}

Also when I try to play a sound, like in the first part of the code above, it doesent work. I cant hear anything.

Please tell me whats wrong? Thanks a bunch!
Kenenth is offline   Reply With Quote
Old 03-14-2011, 05:53 PM   #2 (permalink)
Registered Member
 
Erwin's Avatar
 
Join Date: Oct 2010
Location: Netherlands
Age: 22
Posts: 40
Erwin is on a distinguished road
Default

Looks quite ok from here. What does the log say on the moment the App Crashes? Does it say something about the reason the App terminated? Reading this information always helps a lot..
Erwin is offline   Reply With Quote
Old 03-14-2011, 07:09 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 35
Kenenth is on a distinguished road
Default

The app says: "GDB: Data Formatters temporarily unavailable, will retry after a 'continue'.
Kenenth is offline   Reply With Quote
Old 03-14-2011, 07:49 PM   #4 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

You're probably running out of memory.

You are leaking the audio player each time this method is called. That's not helping your cause.

Also, you can't just drop IBOutlet anywhere you want. That's a .h thing.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Old 03-15-2011, 06:15 AM   #5 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 35
Kenenth is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
You're probably running out of memory.

You are leaking the audio player each time this method is called. That's not helping your cause.

Also, you can't just drop IBOutlet anywhere you want. That's a .h thing.
Thanks-But How can I fix this? Im 3 weeks new to objective c and dont have a clue
Kenenth is offline   Reply With Quote
Old 03-15-2011, 06:21 AM   #6 (permalink)
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,990
BrianSlick has a spectacular aura about
Default

I believe that AVAudioPlayer has a delegate method that fires when the player finishes. You should use that to release the player.
__________________
BriTer Ideas LLC - Professional iOS App Development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is offline   Reply With Quote
Reply

Bookmarks

Tags
app, crash, device, iphone

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 361
11 members and 350 guests
Absentia, akphyo, apatsufas, BinHex, blueorb, fredidf, iGamesDev, Kirkout, MarkC, mottdog, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:26 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0