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);
} } }];
}
IOS 定位 单例的更多相关文章
- iOS - 单例传值 (一)
点击打开链接 iOS - 单例传值 (二) 单例只会对某个类实例化一次/单例类,对单例这个类实例化一次有且仅有一个对象 你单例初始化,只能初始化一次,然后你指向的对象,其实都是指向一个内存地址, ...
- [iOS]封装单例类
[iOS]封装单例类 今天在学习iOS的SQLite开发,发现在需要使用SQLite的每个视图中,都需要对数据库进行打开或关闭,觉得挺麻烦的:于是在想能否写个单例类对这些操作进行封(因以前一直在使用D ...
- iOS登录单例
iOS登录单例 一,工程图. 二,代码. UserInfo.h #import <Foundation/Foundation.h> @interface UserInfo : NSObje ...
- iOS 创建单例的两种方法
创建一个单例很多办法.我先列举一个苹果官方文档中的写法. [cpp] view plaincopy static AccountManager *DefaultManager = nil; + (Ac ...
- iOS设计模式 - 单例
备注:只能通过类的类方法才能创建单例类的实例,[[类名 alloc]init]创建实例没有用的. 原理图 说明 1. 单例模式人人用过,严格的单例模式很少有人用过 2. 严格的单例模式指的是无法通过常 ...
- iOS之单例
今天在看多线程同步时,突然想到了单例的同步问题.自从dispatch_once出现后,我们创建单例非常简单且安全: static dispatch_once_t pred; static Single ...
- iOS快速单例宏
// 单例 #define DECLARE_SHARED_INSTANCE(className) \ + (className *)sharedInstance; #define IMPLEMENT_ ...
- iOS 之单例,代理,通知,KVO,Block全能解析
//单例 //.h + (Instannce *)shareInstance; //.m static Instannce *instance = nil; @implementation Insta ...
- iOS利用单例实现不同界面间的数据传输
首先写一个单例类,继承NSObject check.h文件中 @property(strong ,nonatomic) UITable * Table; @property(strong ,nonit ...
随机推荐
- hdu 5611 Baby Ming and phone number(模拟)
Problem Description Baby Ming collected lots of cell phone numbers, and he wants to sell them for mo ...
- 2301: [HAOI2011]Problem b
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4164 Solved: 1888[Submit] ...
- Python3.5 queue模块详解
queue介绍 queue是python中的标准库,俗称队列,可以直接import 引用,在python2.x中,模块名为Queue 在python中,多个线程之间的数据是共享的,多个线程进行数据交换 ...
- hibernate jpa 2.0 报错Hibernate cannot unwrap interface java.sql.Connection
今天在做报表的时候,利用Hibernate JPA 2.0需要获取数据库连接com.sql.Connection的时候获取不到,网上说用这种方式解决: entityManager.getTransac ...
- MATLAB快速注释方法
觉得有用,未免以后忘记,收藏了.原文来自:http://i.azpala.com/2008/09/18/matlab-multi-line-comment/ A. %{ 若干语句 %} B. 多行注释 ...
- XML读写
private string fileName = HttpContext.Current.Server.MapPath("~/Student.xml"); protected v ...
- JSP脚本元素上机手册
L3 <JSP基础>上机手册 内容回顾 脚本元素<%! %> <%= %> <% %> 注释元素 JSP指令元素 JSP动作元素 上机目标 掌握脚本元素 ...
- (转) Java程序员应该知道的10个调试技巧
原地址:http://www.csdn.net/article/2012-09-03/2809495-java-debugging-tips-with-eclipse 调试可以帮助识别和解决应用程序缺 ...
- C++中const
[const] 0.普通const对象定义在栈空间中 { ; ; cout << &a << ' ' << &b; } Result: 0x22ab ...
- XML巩固
一.XML基础 1.XML区分大小写, 2.XML属性值必须有引号(单引双引均可) 3.XML必须有根元素 4.一些特殊字符的需要用实体引用来替换 < < 小于 > > 大于 ...