title: Region based local notification
body: <p>Im currently working with the "Regions" Sample code:
  <a href="https://developer.apple.com/library/ios/#samplecode/Regions/Introduction/Intro.h" rel="nofollow">https://developer.apple.com/library/ios/#samplecode/Regions/Introduction/Intro.h</a> tml#//apple_ref/doc/uid/DTS40010726-Intro-DontLinkElementID_2</p>
  
  <p>I'd like to take it a step further and generate, or fire, a notifcation when the user exits the region (can be for both enter &amp; exit, i don't mind, whatever is easiest for an initial implementation).</p>
  
  <p>I have been looking at the CLLocation Class reference, Location Awareness Programming Guide and Local and Push Notification Programming guide. And im suffering from information overload.</p>
  
  <p>Many thanks :)</p>
  
  <p>EDIT: I think i may have an idea which solves the problem:
  in the RegionsViewController implementation file there is this:</p>
  
  <pre><code>- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region        {
      NSString *event = [NSString stringWithFormat:@"didExitRegion %@ at %@", region.identifier, [NSDate date]];
  
      [self updateWithEvent:event];
  }
  </code></pre>
  
  <p>Since i want to implement a local notification when the user exits the designated region boundary i've input this:</p>
  
  <pre><code>- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
      NSString *event = [NSString stringWithFormat:@"didExitRegion %@ at %@", region.identifier, [NSDate date]];
      [self updateWithEvent:event];
      //implement local notification: 
      UIApplication *app                = [UIApplication sharedApplication];
      UILocalNotification *notification = [[UILocalNotification alloc] init];
      [[UIApplication sharedApplication] cancelAllLocalNotifications];
  
      if (notification == nil)
          return;
  
      notification.alertBody = [NSString stringWithFormat:@"Did You Lock Your House?"];
      notification.alertAction = @"Lock House";
      notification.soundName = UILocalNotificationDefaultSoundName; 
      notification.applicationIconBadgeNumber = 1;
      [app presentLocalNotificationNow:notification];
  
      [notification release];
  }
  </code></pre>
  
  <p>Could somebody advice me as to whether this is correct, or if there are any recommendations? (apologies for the poor formatting)</p>