IKLocation 1.0

IKLocation 1.0

测试已测试
语言语言 Obj-CObjective C
许可证 BSD
发布最新发布2014年12月

Andres Canal维护。



如果您需要在应用程序的多个部分获取设备位置,则CLLocationManager可能是一个解决方案。CLLocationManager是一个包装器,用于避免在应用程序中多次使用CLLocationManager。当位置可用或调用refresh方法时,所有添加到IKLocation的委托都会收到通知。IKLocation会自动删除when those are deallocated。

安装和使用

  1. IKLocation.hIKLocation.m复制到您的项目中。
  2. 当您想要应用程序提示用户允许访问位置时,请调用[IKLocation sharedClient]
  3. 实现IKLocationDelegate
  4. 添加实现委托的所有对象。[[IKLocation sharedLocation] setDelegate:self];
  5. 实现ikManager:didUpdateToLocation:fromLocation:以及如果需要的话,实现ikManagerDidFailWithError:

您可以添加任何数量的委托。包装器使用NSPointerArray来避免引用循环。

应用程序还公开以下属性

  • location: (CLLocation *) 当前位置
  • oldLocation: (CLLocation *) 前一个位置
  • latitude: (CGFloat) 当前纬度
  • longitude: (CGFloat) 当前经度
  • city: (NSString *) 当前城市
  • state: (NSString *) 当前州
  • country: (NSString *) 当前国家

应用程序还公开以下方法

  • isLocationAvailable: 如果可以获得位置,则返回true。
  • refresh: 更新位置。