title: Connect UISwitch with event in other view controller
body: <p>i have 2 view controller the first one is main view controller and will run music when the view controller load and the other view controller is settings that content an UISwitch so what i want is when the user go to setting view controller and turn switch off then the music will stop in the main view
  here is the code</p>
  
  <p>main.h</p>
  
  <pre><code>#import&lt;AVFoundation/AVAudioPlayer.h&gt;
  
  @interface main : UIViewController
  {
  
  AVAudioPlayer *audioPlayer;
  BOOL didInitialize;
  </code></pre>
  
  <p>}</p>
  
  <p>main.m</p>
  
  <pre><code>static BOOL didInitialize = NO;
  if (didInitialize == YES)
  return;
  didInitialize = YES;
  //Add Audio Sound to the current View Controller
  NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/MLGBoxSoundTrack.mp3", [[NSBundle mainBundle] resourcePath]]];
  
  NSError *error;
  audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&amp;error];
  audioPlayer.numberOfLoops = -1; // -1 for looping forever
  
  //    audioPlayer.volume = 0.5; // 0.0 - no volume; 1.0 full volume
  //    NSLog(@"%f seconds played so far", audioPlayer.currentTime);
  //    audioPlayer.currentTime = 5; // jump to the 10 second mark
  //    [audioPlayer pause];
  //    [audioPlayer stop]; // Does not reset currentTime; sending play resumes
  
  if (audioPlayer == nil)
  {
      NSLog(@"No Audio Player");
  }
  else
  {
      [audioPlayer play];
  }
  //End Audio Sound
  </code></pre>