码迷,mamicode.com
首页 > 移动开发 > 详细

IOS 定位 单例

时间:2014-04-29 10:12:46      阅读:534      评论:0      收藏:0      [点我收藏+]

标签:des   blog   os   io   for   re   

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
+ (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);
             }
              
         }
  
     }];
}

  

IOS 定位 单例,码迷,mamicode.com

IOS 定位 单例

标签:des   blog   os   io   for   re   

原文地址:http://www.cnblogs.com/joesen/p/3698630.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!