Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ulquiorra

macrumors member
Original poster
Jun 17, 2009
38
0
Hello all quick question how can I let my app not crash when handling a nil exception

this is the code I have and it works

Code:
movies = [movieDictionary objectForKey:@"movieID"];

	NSLog(@"callVideoSetting");
	

	NSString *path = [[NSBundle mainBundle] pathForResource:movies ofType:@"m4v"];
	
	if (!path) {
		NSLog(@"exception!!");
           // DO not crash my program 
	}
	
	NSURL *movie = [NSURL fileURLWithPath:path];
	
	//NSURL *movie = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:movies ofType:@"m4v"]];
	//path for resource moet id worden 
	theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movie];
	[theMovie setOrientation:UIDeviceOrientationPortrait animated:NO];
	theMovie.movieControlMode = MPMovieControlModeHidden;
	[theMovie setScalingMode:MPMovieScalingModeAspectFit];
	theMovie.backgroundColor = [ UIColor whiteColor];


So how can I make sure my app doesn't crash when handling this nil exception and just do .. well nothing..
 
may i suggest trying the following:
- after the right curly brace following the "do not crash my program" comment, type the word "else"
- add a left curly brace "{"
- press the down arrow key 11 times, so that the cursor goes under the rest of the text
- add a right curly brace "}"

good luck. :)
 
i figured it out..... I must be sleepinggggggg hahaha still thanks though ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.