替换“目的” CLLocationManager的属性 [英] Replacement for "purpose" property of CLLocationManager

查看:137
本文介绍了替换“目的” CLLocationManager的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 6中,CLLocationManager的目的属性描述使用位置服务的原因( @property(copy,nonatomic)NSString *目的)已被弃用。



Apple提出了什么替代品(如果有)?

解决方案

在iOS 6中替换目的属性是一个名为 NSLocationUsageDescription 的新Info.plist键(aka位置使用说明)。



关键是记录在信息属性列表键引用,但不幸的是它没有提及与目的属性的弃用说明。然而, CLLocationManager.h 有这个注释:



< blockquote>

* 已弃用。使用键NSLocationUsageDescription在Info.plist中设置目的字符串。


在您的代码中,您可以设置键和 purpose 属性(但如果/当该方法在将来实际删除时,您可能需要检查位置管理器是否首先响应该选择器)。



如果在iOS 6下运行,位置管理器将使用该键。

当在小于iOS 6下运行时,键将被忽略,并且目的属性。


In iOS 6, the purpose property of CLLocationManager, to describe the reason for using location services (@property(copy, nonatomic) NSString *purpose) has been deprecated.

What replacement, if any, is proposed by Apple?

解决方案

The replacement for the purpose property in iOS 6 is a new Info.plist key named NSLocationUsageDescription (aka "Privacy - Location Usage Description").

The key is documented in the Information Property List Key Reference but unfortunately it's not mentioned with the deprecation note of the purpose property.

However, the CLLocationManager.h does have this comment:

* Deprecated. Set the purpose string in Info.plist using key NSLocationUsageDescription.

In your code, you could set both the key and the purpose property (but you may want to check if the location manager responds to that selector first if/when that method is actually removed in the future).

If running under iOS 6, the location manager will use the key.
When running under less than iOS 6, the key will be ignored and the purpose property will be used.

这篇关于替换“目的” CLLocationManager的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆