【发布时间】:2014-12-22 07:28:27
【问题描述】:
我在我的 iOS8 兼容应用程序中编写了以下代码。该应用程序在 iOS8 上运行良好,令我惊讶的是,iOS7。我的问题是,为什么这段代码在 iOS7 上不会崩溃?
#import <CoreLocation/CoreLocation.h>
.
.
CLAuthorizationStatus authStatus = [CLLocationManager authorizationStatus];
.
// TODO some of these statuses are iOS8 only not iOS7 - need to check.
if ((authStatus == kCLAuthorizationStatusAuthorized) || (authStatus == kCLAuthorizationStatusAuthorizedAlways) ||
(authStatus == kCLAuthorizationStatusAuthorizedWhenInUse)) {
<some actual code>
}
常量 kCLAuthorizationStatusAuthorizedWhenInUse 和 kCLAuthorizationStatusAuthorizedAlways 是在 iOS8 中引入的,所以当我试图在 iOS7 模拟器中运行它时,我期待着悲剧,但它运行得很好。这是我在真正的 iOS7 设备上应该担心的问题(我现在没有设备了),还是有什么东西说这个代码在我不知道的 iOS7 上有效?
提前谢谢你。
【问题讨论】:
标签: ios ios7 ios8 core-location