handling exceptions with moviecontroller

Discussion in 'iOS Programming' started by ulquiorra, Sep 23, 2009.

  1. ulquiorra macrumors member

    Jun 17, 2009
    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

    movies = [movieDictionary objectForKey:@"movieID"];
    	NSString *path = [[NSBundle mainBundle] pathForResource:movies ofType:@"m4v"];
    	if (!path) {
               // 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..
  2. drivefast macrumors regular

    Mar 13, 2008
    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. :)
  3. ulquiorra thread starter macrumors member

    Jun 17, 2009
    i figured it out..... I must be sleepinggggggg hahaha still thanks though ;)

Share This Page