title: How to activate a sound in an if statement (objective-c)
body: <p>I am writing a code for a game and I am almost done. I am at the point where I am trying to input sounds. What I did was insert the audiotoolbox framework and:</p>
  
  <p>.h </p>
  
  <pre><code>@interface GameViewController : UIViewController &lt;ADBannerViewDelegate&gt; {
  
      SystemSoundID JumpSoundID;
  }
  
  -(void)jumpSound;
  
  @end
  </code></pre>
  
  <p>and .m </p>
  
  <pre><code>@implementation GameViewController
  
  -(void)jumpSound {
      AudioServicesPlaySystemSound(JumpSoundID);
      NSURL *jumpURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"jump2" ofType:@"wav"]];
      AudioServicesCreateSystemSoundID((__bridge CFURLRef)jumpURL, &amp;JumpSoundID);
  
  }
  -(void)fishSound {
      AudioServicesPlaySystemSound(FishSoundID);
      NSURL *fishURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"pickupFish" ofType:@"wav"]];
      AudioServicesCreateSystemSoundID((__bridge CFURLRef)fishURL, &amp;FishSoundID);
  }
  -(void)gameOverSound {
      AudioServicesPlaySystemSound(GameOverSoundID);
      NSURL *gameOverURL = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"gameover" ofType:@"wav"]];
      AudioServicesCreateSystemSoundID((__bridge CFURLRef)gameOverURL, &amp;GameOverSoundID);
  } 
  </code></pre>
  
  <p>Then I thought I could simply call on the methods in the if statement like so: </p>
  
  <pre><code> if (CGRectIntersectsRect(ball.frame, platform.frame) &amp;&amp; (upMovement &lt;= -1 )){
      [self bounce];
      [self iceblockfall];
      [self jumpSound]; //this is what I thought I could call &lt;&lt;----------------
      if (iceblock6Used == NO) {
          addedScore = 1;
          iceblock6Used = YES;
      }
   }
  </code></pre>
  
  <p>But it is not working. Whenever I run it I get this error:</p>
  
  <pre><code>2014-02-28 18:03:52.383 BounceIt[528:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
  </code></pre>
  
  <p><em>*</em> First throw call stack..</p>
  
  <p>What is the problem here. I am confused and can't find anything to help me. Am I making the wrong move by trying to call it as a method? </p>