handling exceptions with moviecontroller

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

  1. ulquiorra macrumors member

    Joined:
    Jun 17, 2009
    #1
    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..
     
  2. drivefast macrumors regular

    Joined:
    Mar 13, 2008
    #2
    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

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

Share This Page