在 Swift 2 Xcode 7 Beta 4 中设置基于位置的提醒时出错

Error when setting location based reminders in Swift 2 Xcode 7 Beta 4

我想设置基于位置的提醒。这是我的代码:

    let locattionnotification = UILocalNotification()
    locattionnotification.alertBody = textAllert
    locattionnotification.regionTriggersOnce = false
    locattionnotification.region = CLCircularRegion(circularRegionWithCenter: CLLocationCoordinate2D(latitude:
        mylatitude, longitude: mylongitude), radius: 300.0, identifier: "Location1")
    UIApplication.sharedApplication().scheduleLocalNotification(locattionnotification)

mylatitude 和 mylongitude 是双精度值。问题是,Xcode 正在抱怨:

init(circularRegionWithCenter:radius:identifier:)' is unavailable: APIs >deprecated as of iOS 7 and earlier are unavailable in Swift

有没有更好的方法来设置基于区域的提醒?我已经做了一些研究,发现 CLRegion 也可以,但无法弄清楚如何使用手动设置坐标进行设置。

您可以使用 another CLCircularRegion constructor:

locattionnotification.region = CLCircularRegion(center: CLLocationCoordinate2D(latitude:
    mylatitude, longitude: mylongitude), radius: 300.0, identifier: "Location1")