Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在Swift中初始化CLCircularRegion_Ios_Swift_Geofencing_Clcircleregion - Fatal编程技术网

Ios 在Swift中初始化CLCircularRegion

Ios 在Swift中初始化CLCircularRegion,ios,swift,geofencing,clcircleregion,Ios,Swift,Geofencing,Clcircleregion,我对iOS编程相当陌生,正在自学如何使用Swift。我需要为我为班级制作的应用程序设置地理围栏。我的问题是,在初始化CLCircularRegion时,我收到一个错误,上面写着“使用未声明的类型‘center’”。我遵循了苹果开发者网站上的文档,不知道自己做错了什么。任何帮助都将不胜感激。多谢各位 import UIKit import MapKit import CoreLocation class ViewController: UIViewController, MKMapViewDel

我对iOS编程相当陌生,正在自学如何使用Swift。我需要为我为班级制作的应用程序设置地理围栏。我的问题是,在初始化CLCircularRegion时,我收到一个错误,上面写着“使用未声明的类型‘center’”。我遵循了苹果开发者网站上的文档,不知道自己做错了什么。任何帮助都将不胜感激。多谢各位

import UIKit
import MapKit
import CoreLocation

class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {

@IBOutlet var mapView: MKMapView!

var manager = CLLocationManager()

@IBAction func startMonitoring(sender: AnyObject) {
    // 43.039278, -87.932479 mccormick hall location
    var latitude:CLLocationDegrees = 43.039278
    var longitude:CLLocationDegrees = -87.932479
    var center:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
    var radius:CLLocationDistance = CLLocationDistance(10.0)
    var identifier:String = "vicmic"

    var geoRegion:CLCircularRegion = CLCircularRegion(center: center, radius: radius, identifier: identifier)

}


override func viewDidLoad() {
    super.viewDidLoad()

    // Core Location
    manager.delegate = self
    manager.desiredAccuracy = kCLLocationAccuracyBest
    manager.requestWhenInUseAuthorization()
    manager.startUpdatingLocation()

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

大体上。。。。代码似乎还可以

1) 尝试在类型注释之前留下空格,例如从
var center:CLLocationCoordinate2D
到此
var center:CLLocationCoordinate2D


2) 尝试清理您的派生数据,重新启动Xcode..

我不敢相信@TonyMkenu,但添加空格修复了所有问题!!这就是我所做的一切。非常感谢。