替换“目的” CLLocationManager的属性 [英] Replacement for "purpose" property of 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屋!