Corelocation area monitoring, from crazy iOS handouts
1. Lead corelocation frame, import header file
#import <CoreLocation/CoreLocation.h>
2. Add location management as member variable, add lazy load
@property (Nonatomic,strong) Cllocationmanager *locmgr;
1 /**2 * Lazy Loading3 */4-(Cllocationmanager *) Locmgr5 {6 if(_locmgr = =Nil) {7_locmgr =[[Cllocationmanager alloc]init];8_locmgr.Delegate=Self ;9 }Ten return_locmgr; One}
3. Open Area Monitoring
1- (void) Viewdidload2 {3 [Super Viewdidload];4 5 //setting up the center6cllocationcoordinate2d coordinate = Cllocationcoordinate2dmake ( the, the);7 //Set Radius8Cllocationdistance distance = -;9 //Create a monitoring areaTenClregion *region = [[clcircularregion alloc]initwithcenter:coordinate radius:distance Identifier:@" Region"]; One A //Start Area detection - [Self.locmgr startmonitoringforregion:region]; -}
4. Adding Proxy methods
1 #pragmaMark-cllocationmanagerdelegate2- (void) Locationmanager: (Cllocationmanager *) Manager didstartmonitoringforregion: (clregion *) Region3 {4NSLog (@"successfully open area monitoring");5 }6 7- (void) Locationmanager: (Cllocationmanager *) Manager didenterregion: (clregion *) Region8 {9NSLog (@"you've entered the surveillance area .");Ten } One A- (void) Locationmanager: (Cllocationmanager *) Manager didexitregion: (clregion *) Region - { -NSLog (@"you've left the surveillance area ."); the - //Closed Zone monitoring - if([Region.identifier isequal:@" Region"]) { - [Self.locmgr stopmonitoringforregion:region]; + } - +}
IOS Corelocation Regional Monitoring