Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

ios - Replacement for "purpose" property of CLLocationManager

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...