如果您需要在应用程序的多个部分获取设备位置,则CLLocationManager
可能是一个解决方案。CLLocationManager
是一个包装器,用于避免在应用程序中多次使用CLLocationManager
。当位置可用或调用refresh
方法时,所有添加到IKLocation的委托都会收到通知。IKLocation
会自动删除when those are deallocated。
IKLocation.h
和IKLocation.m
复制到您的项目中。[IKLocation sharedClient]
。IKLocationDelegate
[[IKLocation sharedLocation] setDelegate:self];
ikManager:didUpdateToLocation:fromLocation:
以及如果需要的话,实现ikManagerDidFailWithError:
您可以添加任何数量的委托。包装器使用NSPointerArray
来避免引用循环。
应用程序还公开以下属性
(CLLocation *)
当前位置(CLLocation *)
前一个位置(CGFloat)
当前纬度(CGFloat)
当前经度(NSString *)
当前城市(NSString *)
当前州(NSString *)
当前国家应用程序还公开以下方法