2012-01-17 42 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