darcyliu/acm — pull request #1 by Chutina (2013-03-06 16:52:15+00:00)
Title: - (IBAction)addRegion {     if ([CLLocationManager regionMonitoringAvail...

...able]) { // Create a new region based on the center of the map view. CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(regionsMapView.centerCoordinate.latitude, regionsMapView.centerCoordinate.longitude); CLRegion *newRegion = [[CLRegion alloc] initCircularRegionWithCenter:coord radius:1000.0 identifier:[NSString stringWithFormat:@"%f, %f", regionsMapView.centerCoordinate.latitude, regionsMapView.centerCoordinate.longitude]]; // Create an annotation to show where the region is located on the map. RegionAnnotation *myRegionAnnotation = [[RegionAnnotation alloc] initWithCLRegion:newRegion]; myRegionAnnotation.coordinate = newRegion.center; myRegionAnnotation.radius = newRegion.radius; [regionsMapView addAnnotation:myRegionAnnotation]; [myRegionAnnotation release]; // Start monitoring the newly created region. [locationManager startMonitoringForRegion:newRegion desiredAccuracy:kCLLocationAccuracyBest]; [newRegion release]; } else { NSLog(@"Region monitoring is not available."); } } /* This method adds the region event to the events array and updates the icon badge number. */ - (void)updateWithEvent:(NSString *)event { // Add region event to the updates array. [updateEvents insertObject:event atIndex:0]; // Update the icon badge number. [UIApplication sharedApplication].applicationIconBadgeNumber++; if (!updatesTableView.hidden) { [updatesTableView reloadData]; } }