★ 初期化
let locationManager = CLLocationManager()
let locationManager: CLLocationManager = CLLocationManager()
★ Delegateの設定
locationManager.delegate = self
★ 領域監視を登録する
let coordinate = CLLocationCoordinate2DMake(location.latitude, location.longitude)
let region = CLCircularRegion(center: coordinate, radius: 200, identifier: location.pinTitle)
locationManager.startMonitoringForRegion(region)
★ 領域監視を登録した際に呼ばれるDelegate
func locationManager(manager: CLLocationManager, didStartMonitoringForRegion region: CLRegion) {
print(region.identifier + "が登録されました")
}
// iOS8以降 info.plistに以下を記述する必要がある
// このApp使用中のみ許可を要求
<key>NSLocationWhenInUseUsageDescription</key>
<string>The spirit of stack overflow is coders helping coders</string>
// 常に許可を要求
<key>NSLocationAlwaysUsageDescription</key>
<string>I have learned more on stack overflow than anything else</string>