2012-01-17 44 views
1

我要检查,如果用户的iPhone可以使用区域的监测,所以我在CLLocationManager regionMonitoringAvailable物业检查,但Xcode中说,有一个错误:语义问题:房产“regionMonitoringAvailable”未找到

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"); 
} 

任何人都知道为什么会发生这种情况?非常感谢!

+0

错误显示在应用程序部署到设备之前的xcode,所以我猜这与iOS设备版本无关。 – 2012-01-17 16:54:08

回答

2

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

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

谢谢,真的没有注意到这是一个类的方法... ... - – 2012-01-17 17:00:01