【问题标题】:Semantic Issue: Property 'regionMonitoringAvailable' not found语义问题:找不到属性“regionMonitoringAvailable”
【发布时间】:2012-01-17 16:42:28
【问题描述】:

我想检查用户的iphone是否可以使用区域监控,所以我用CLLocationManager中的regionMonitoringAvailable属性检查,但是xcode说有错误:

error: Semantic Issue: Property 'regionMonitoringAvailable' not found on object of type 'CLLocationManager *'

这是我的代码:

CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;

if (locationManager.regionMonitoringAvailable) {
    NSLog(@"test");
}

有人知道为什么会这样吗?非常感谢!

【问题讨论】:

  • 在应用部署到设备之前xcode中显示错误,所以我猜这与iOS设备版本无关。

标签: iphone core-location region


【解决方案1】:

这是一个类方法,而不是实例方法。所以你需要这个:

if ([CLLocationManager regionMonitoringAvailable]) {
    NSLog(@"test");
}

【讨论】:

    猜你喜欢
    • 2018-01-25
    • 2014-04-03
    • 2017-07-20
    • 2021-09-16
    • 2015-06-05
    • 1970-01-01
    • 2018-09-10
    • 2020-01-21
    • 1970-01-01
    相关资源
    最近更新 更多