IOS 定位 单例

+ (SCLocationController *)sharedController
{
static SCLocationController *sharedController = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedController = [[self alloc]init];
}); return sharedController;
} - (id)init
{
self = [super init];
if (self) {
_locationManager = [[CLLocationManager alloc]init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.distanceFilter = 30; // Meters.
}
return self;
} #pragma mark - Location Manager
#pragma mark - CLLocationManagerDelegate
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
[_locManager stopUpdatingLocation]; CLGeocoder *reverseGeocoder=[[CLGeocoder alloc] init];
[reverseGeocoder reverseGeocodeLocation:newLocation completionHandler:^(NSArray *array, NSError *error)
{
CLPlacemark *placeMark = [array lastObject];
if (placeMark != nil)
{
state = [placeMark.addressDictionary objectForKey:@"State"];
city = [placeMark.addressDictionary objectForKey:@"City"];
subLocality = [placeMark.addressDictionary objectForKey:@"SubLocality"]; if (city.length > 0) {
NSLog(@"%@-%@-%@",state,city,subLocality);
}
else{
NSLog(@"%@-%@",state,subLocality);
} } }];
}

  

上一篇:mysql 存储过程:提供查询语句并返回查询执行影响的行数


下一篇:判断mysqli函数里的sql语句是否有错和影响行数