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 07-29-2010, 05:32 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default How to not to make views stack on views? "Running out of memory"

Ok heres my problem: I have many views in my app, and when im moving from view to view those views are using all of my memory... How can change it to when I move to new and old views it release the previous views?

Thanks Adam
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 05:40 PM   #2 (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

How are you moving from view to view?
__________________
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 07-29-2010, 05:46 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
How are you moving from view to view?

Code:
-(IBAction) stage_12 {
	//View Switch
	VIEW *screen = [[VIEW alloc] initWithNibName:nil bundle:nil];
	screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
	[self presentModalViewController:screen animated:YES];
	[screen release];
and this to go back to previous view:


Code:
-(IBAction) bacKToView {
	//Switch View Back Home
	[self dismissModalViewControllerAnimated:YES];
I've been using this way to change views for a while, but since my app contains many many views there stacking on top of each other and eating all my memory away
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 05:50 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

I kinda doubt you are showing enough views for that to be too much of an issue in and of itself. Depends on what is in each view, I suppose.

There are things that will happen automatically when memory runs low, and there are things you should do when the view is not currently being shown. You can dump resources in viewDidDisappear and reload them in viewWillAppear, for example.

And this assumes you aren't leaking anything.
__________________
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 07-29-2010, 05:57 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
I kinda doubt you are showing enough views for that to be too much of an issue in and of itself. Depends on what is in each view, I suppose.

There are things that will happen automatically when memory runs low, and there are things you should do when the view is not currently being shown. You can dump resources in viewDidDisappear and reload them in viewWillAppear, for example.

And this assumes you aren't leaking anything.

Ya, well I just started to us Instruments and I have no leaks! But when im looking under "All Allocations" my Overall Bytes keep growing every time im moving from view to view. I read not to go over like 15, I don't know if this is true or if im even reading this correctly... This is my first day working with Instruments...
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 05:59 PM   #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

Are you experiencing problems?
__________________
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 07-29-2010, 06:02 PM   #7 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Are you experiencing problems?
It's sometimes crashes but it's very rare... It's just I want my code to be solid before I submit it! Oh and I have about 50 views.


Oh by the way! Is the method I'm using to switch views a practical way to move from view to view?
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 06:04 PM   #8 (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

Well, identify the reason for your crashes before exploring too many possible explanations. For example, if it happens in the simulator, it almost certainly is not a memory issue.

I'm partial to navigation controllers, personally.
__________________
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 07-29-2010, 06:23 PM   #9 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Well, identify the reason for your crashes before exploring too many possible explanations. For example, if it happens in the simulator, it almost certainly is not a memory issue.

I'm partial to navigation controllers, personally.
Okay soo I found out the problem... It is the views stacking on top of views, because the app is constantly switching views making the app crash a certain point. So how can I forget the previous views so I can free up memory as I navigate through the app.

Last edited by AdamSubach; 07-29-2010 at 06:25 PM.
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 06:26 PM   #10 (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

How did you find this out?

And how many views are we talking about? What kind of information is on each view?
__________________
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 07-29-2010, 06:41 PM   #11 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
How did you find this out?

And how many views are we talking about? What kind of information is on each view?

I found this about out by running my app through Instruments and every time my apps gets around 11-12 mb the app crashes...

Well right now there is only 10 views but soon to be 50, and they all move in a arithmetic sequence but they sequence can restart back to view 1 and continue. ohh and there are just UIButtons and a pictures on each view connected to audio...
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 07:00 PM   #12 (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

If it is truly a memory issue, you would receive memory warnings. Are you?
__________________
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 07-29-2010, 07:08 PM   #13 (permalink)
Use [code] tags please
 
Join Date: Jun 2009
Location: Jacksonville, FL
Posts: 410
timle8n1 is on a distinguished road
Default

Quote:
Originally Posted by AdamSubach View Post
Code:
-(IBAction) stage_12 {
	//View Switch
	VIEW *screen = [[VIEW alloc] initWithNibName:nil bundle:nil];
	screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
	[self presentModalViewController:screen animated:YES];
	[screen release];
and this to go back to previous view:


Code:
-(IBAction) bacKToView {
	//Switch View Back Home
	[self dismissModalViewControllerAnimated:YES];
I've been using this way to change views for a while, but since my app contains many many views there stacking on top of each other and eating all my memory away
I'm not sure about the memory aspects of this but it does seem like a edge usage of ModalViewControllers. How about something like

Code:
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:THESUPERVIEW cache:YES];
[OLDVIEW removeFromSuperview];
[THESUPERVIEW addSubview:NEWVIEW];
Where THESUPERVIEW is a view containing all the other views - potentially the Window?
OLDVIEW is the view you are leaving
NEWVIEW is the view you are going to

You could create a double linked list representing your view list and then a reusable ViewController that navigates this double linked list.

You could also use a Navigation View Controller and hide the Navigation Bar if you don't want this UI element.
timle8n1 is offline   Reply With Quote
Old 07-29-2010, 07:55 PM   #14 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Okay so im looking at my code and it seems like its not the Views! But its the way im mapping out my project... What I'm doing is, is creating a bunch UIViewControler with subclass's with XIB's. I have about 10 of them right now and in ever class .h and .m I have the same exact code which I think is very inefficient. "I think" Soo from that I'm thinking that the same codes keeps on deploying.

Any Suggestions? Or have I dug a hole to deep?
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 10:06 PM   #15 (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

Ok, it is clear that you do not have enough experience to arrive at the conclusions you are coming up with. So, stop thinking that you know what the issue is, and start coming up with some hard facts.

I asked if you were receiving memory warnings. You did not answer.

When you crash, what message(s) do you receive?

Answer these questions and you'll be closer to a real solution.
__________________
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 07-29-2010, 10:17 PM   #16 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Ok, it is clear that you do not have enough experience to arrive at the conclusions you are coming up with. So, stop thinking that you know what the issue is, and start coming up with some hard facts.

I asked if you were receiving memory warnings. You did not answer.

When you crash, what message(s) do you receive?

Answer these questions and you'll be closer to a real solution.

Memory=No message

And here is the crash log "I dont know if this is what you ment"


Code:
Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0

Thread 0 Crashed:
0   libSystem.B.dylib             	0x000791d0 __kill + 8
1   libSystem.B.dylib             	0x000791c0 kill + 4
2   libSystem.B.dylib             	0x000791b2 raise + 10
3   libSystem.B.dylib             	0x0008d6fa abort + 50
4   libstdc++.6.dylib             	0x00044a20 __gnu_cxx::__verbose_terminate_handler() + 376
5   libobjc.A.dylib               	0x000059ec _objc_terminate + 104
6   libstdc++.6.dylib             	0x00042df2 __cxxabiv1::__terminate(void (*)()) + 46
7   libstdc++.6.dylib             	0x00042e46 std::terminate() + 10
8   libstdc++.6.dylib             	0x00042f16 __cxa_throw + 78
9   libobjc.A.dylib               	0x000048cc objc_exception_throw + 64
10  CoreFoundation                	0x0009be8a +[NSException raise:format:arguments:] + 62
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 10:22 PM   #17 (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

That is a crash log, but what I meant was the Console. This is also where you would receive any memory warnings. If you are not receiving memory warnings, then your issue is not related to using too much memory. When testing on a device, I mean. You most likely won't see it when testing in the simulator. So if you still observe the the crash in the simulator, the problem is almost certainly not due to using too much memory.

So, check the Console. If you run out of memory, you will be told there. If you crash, most of the time you will get a line or two providing some information about the crash.
__________________
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 07-29-2010, 10:48 PM   #18 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Ok I think I got what you where talking about;


Code:
2010-07-29 20:42:49.575 IPHONEAPP[107:307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/2D1C8B55-2774-4E6B-83FF-C2C73C4B4D2B/IPHONEAPP.app> (loaded)' with name 'Stage_2''
*** Call stack at first throw:
(
	0   CoreFoundation                      0x3037cfd3 __exceptionPreprocess + 114
	1   libobjc.A.dylib                     0x321308a5 objc_exception_throw + 24
	2   CoreFoundation                      0x3037ce91 +[NSException raise:format:arguments:] + 68
	3   CoreFoundation                      0x3037cecb +[NSException raise:format:] + 34
	4   UIKit                               0x32526b43 -[UINib instantiateWithOwner:options:] + 1110
	5   UIKit                               0x32527ef9 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 92
	6   UIKit                               0x3249c361 -[UIViewController _loadViewFromNibNamed:bundle:] + 36
	7   UIKit                               0x324025f5 -[UIViewController loadView] + 80
	8   UIKit                               0x323878ab -[UIViewController view] + 30
	9   UIKit                               0x32396475 -[UIViewController viewControllerForRotation] + 20
	10  UIKit                               0x323963f7 -[UIViewController _visibleView] + 66
	11  UIKit                               0x323963af -[UIViewController rotatingContentViewForWindow:] + 14
	12  UIKit                               0x3240e925 -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 192
	13  UIKit                               0x3240dc4f -[UIWindow _setRotatableClient:toOrientation:duration:force:] + 674
	14  UIKit                               0x3240cbbb -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 550
	15  UIKit                               0x3240c503 -[UIViewController presentModalViewController:withTransition:] + 1986
	16  UIKit                               0x00585771 -[UIViewControllerAccessibility(SafeCategory) presentModalViewController:withTransition:] + 28
	17  UIKit                               0x3240bc77 -[UIViewController presentModalViewController:animated:] + 58
	18  IPHONEAPP                         0x000028c7 -[Stage_1 stage_2] + 66
	19  CoreFoundation                      0x303077ad -[NSObject(NSObject) performSelector:withObject:withObject:] + 24
	20  UIKit                               0x32383829 -[UIApplication sendAction:to:from:forEvent:] + 84
	21  UIKit                               0x323837c9 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 32
	22  UIKit                               0x3238379b -[UIControl sendAction:to:forEvent:] + 38
	23  UIKit                               0x323834ed -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 356
	24  UIKit                               0x32383b3b -[UIControl touchesEnded:withEvent:] + 342
	25  UIKit                               0x323824ed -[UIWindow _sendTouchesForEvent:] + 368
	26  UIKit                               0x32381e67 -[UIWindow sendEvent:] + 262
	27  UIKit                               0x3237db5b -[UIApplication sendEvent:] + 298
	28  UIKit                               0x3237d507 _UIApplicationHandleEvent + 5022
	29  GraphicsServices                    0x31a78147 PurpleEventCallback + 666
	30  CoreFoundation                      0x30352aab __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
	31  CoreFoundation                      0x3035484f __CFRunLoopDoSource1 + 166
	32  CoreFoundation                      0x3035562d __CFRunLoopRun + 520
	33  CoreFoundation                      0x302fe8eb CFRunLoopRunSpecific + 230
	34  CoreFoundation                      0x302fe7f3 CFRunLoopRunInMode + 58
	35  GraphicsServices                    0x31a776ef GSEventRunModal + 114
	36  GraphicsServices                    0x31a7779b GSEventRun + 62
	37  UIKit                               0x323272a7 -[UIApplication _run] + 402
	38  UIKit                               0x32325e17 UIApplicationMain + 670
	39  IPHONEAPP                       0x0000210b main + 42
	40  IPHONEAPP                         0x000020dc start + 40
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
Data Formatters unavailable (Error calling dlopen for: "/Developer/usr/lib/libXcodeDebuggerSupport.dylib": "dlopen(/Developer/usr/lib/libXcodeDebuggerSupport.dylib, 10): no suitable image found.  Did find:
	/Developer/usr/lib/libXcodeDebuggerSupport.dylib: open() failed with errno=24
	/Developer/usr/lib/libXcodeDebuggerSupport.dylib: stat() failed with errno=10289664")
(gdb)
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 10:51 PM   #19 (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

Ok, let's start here:

Quote:
Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/2D1C8B55-2774-4E6B-83FF-C2C73C4B4D2B/IPHONEAPP.app> (loaded)' with name 'Stage_2'
Is there an issue with the name of this XIB?
__________________
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 07-29-2010, 11:05 PM   #20 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
Ok, let's start here:



Is there an issue with the name of this XIB?
Not that im seeing...
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 11:24 PM   #21 (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

How about the way you call it? The call stack mentions [Stage_1 stage_2] which would be a different spelling. Post the code that you use to go to Stage_2.
__________________
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 07-29-2010, 11:27 PM   #22 (permalink)
Use [code] tags please
 
Join Date: Jun 2009
Location: Jacksonville, FL
Posts: 410
timle8n1 is on a distinguished road
Default

Quote:
Originally Posted by AdamSubach View Post
Not that im seeing...
Could it be stage_2 instead of Stage_2? I think XIBs are case sensitive but I'm in a taxi and can't check
timle8n1 is offline   Reply With Quote
Old 07-29-2010, 11:36 PM   #23 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
How about the way you call it? The call stack mentions [Stage_1 stage_2] which would be a different spelling. Post the code that you use to go to Stage_2.
I checked it and im not seeing anything incorrect but take a look:

Code:
-(IBAction)stage_2 {
	//Switch Views
	Stage_2 *screen = [[Stage_2 alloc] initWithNibName:nil bundle:nil];
	screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
	[self presentModalViewController:screen animated:YES];
	[screen release];
}
AdamSubach is offline   Reply With Quote
Old 07-29-2010, 11:52 PM   #24 (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

That looks fine.

The data formatters message could indicate a memory issue. Add log messages to the didReceiveMemoryWarning methods and find out if those are triggering.

Really there are too many possibilities to give you much help without more code.
__________________
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 07-30-2010, 12:04 AM   #25 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 106
AdamSubach is on a distinguished road
Default

Quote:
Originally Posted by BrianSlick View Post
That looks fine.

The data formatters message could indicate a memory issue. Add log messages to the didReceiveMemoryWarning methods and find out if those are triggering.

Really there are too many possibilities to give you much help without more code.
Code:
#import "Stage_2.h"
#import "Stage_3.h"

#import "IPHONEAPP.h"

#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>

@implementation Stage_2

@synthesize audioPlayer, audioPlayer2;

//Stage_3 Parts- View/Alert/Auido
//
//
-(IBAction) stage_3 {
	//View Switch
	Stage_3 *screen = [[Stage_3 alloc] initWithNibName:nil bundle:nil];
	screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
	[self presentModalViewController:screen animated:YES];
	[screen release];
	//Audio-Make sure the audio is at the start of the stream.
	self.audioPlayer.currentTime = 0;
	
	[self.audioPlayer play];	
}

//backHome Parts- View/Alert/Vibrate/Audio
//
//

-(IBAction)backHome {
	//View Switch
	IPHONEAPPViewController *screen = [[IPHONEAPPViewController alloc] initWithNibName:nil bundle:nil];
	screen.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
	[self presentModalViewController:screen animated:YES];
	[screen release];
	//Alert
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Woops..." 
												   delegate:self cancelButtonTitle:@"Try Again?" otherButtonTitles:nil];
	[alert show];
	[alert release];
	//Vibrate
	AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
	//Audio-Make sure the audio is at the start of the stream.
	self.audioPlayer2.currentTime = 0;
	
	[self.audioPlayer2 play];	
	
}

//viewDidLoad Parts
//
//
- (void) viewDidLoad {
	
//Sound "Foward"
//
//
	NSString *filePath = [[NSBundle mainBundle] pathForResource:@"fowardSound"ofType:@"mp3"];
	NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
	self.audioPlayer = [[AVAudioPlayer alloc] 
						initWithContentsOfURL:fileURL error:nil];
	
	[self.audioPlayer prepareToPlay];
	
	[filePath release];
	[fileURL release];
//Sound "Back"
//
//
	NSString *filePath2 = [[NSBundle mainBundle] pathForResource:@"backSound"ofType:@"mp3"];
	NSURL *fileURL2 = [[NSURL alloc] initFileURLWithPath:filePath2];
	self.audioPlayer2 = [[AVAudioPlayer alloc] 
						initWithContentsOfURL:fileURL2 error:nil];
	
	[self.audioPlayer2 prepareToPlay];
	
	[filePath2 release];
	[fileURL2 release];
	
	[super viewDidLoad];
	
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}



- (void)dealloc {
	[audioPlayer release];
	[audioPlayer2 release];
    [super dealloc];
}


@end
AdamSubach is offline   Reply With Quote
Reply

Bookmarks

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: 339
16 members and 323 guests
appservice, bignoggins, dermotos, Domele, EXOPTENDAELAX, guusleijsten, Hamad, heshiming, linkmx, mariano_donati, Objective Zero, Paul Slocum, Rudy, Sloshmonster, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,653
Threads: 94,115
Posts: 402,888
Top Poster: BrianSlick (7,990)
Welcome to our newest member, ohmniac
Powered by vBadvanced CMPS v3.1.0

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