Ios 在objc func中初始化CLPlacemark时出错
我有以下抽头处理功能Ios 在objc func中初始化CLPlacemark时出错,ios,objective-c,swift,Ios,Objective C,Swift,我有以下抽头处理功能 @objc func handleTap(sender: UITapGestureRecognizer) { switch sender.state { case .ended: let tapLocation = sender.location(in: mapView) let coordinate = mapView.convert(tapLocation, toCoordinateFrom: mapView)
@objc func handleTap(sender: UITapGestureRecognizer) {
switch sender.state {
case .ended:
let tapLocation = sender.location(in: mapView)
let coordinate = mapView.convert(tapLocation, toCoordinateFrom: mapView)
var tapLocationPlacemark = CLPlacemark()
//rest of code is irrelevant
default: break
}
}
问题是,当我在函数中初始化变量var-tapLocationPlacemark=CLPlacemark()
时,如果我在没有初始化的情况下声明该变量(var-tapLocationPlacemark:CLPlacemark
),则在函数结束时单击某个地方会产生EXC\u BAD\u ACCES错误或者我声明并初始化它为一个全局变量,错误就消失了
我在文件开头导入了CoreLocation,根据Objective-C文档,Objective-C中也存在CLPlacemark,那么会出现什么问题呢
错误详细说明:
tapLocationPlacemark的打印说明:
表达式生成错误:错误:/var/folders/z6/3w15l2r93vvf0237nsdxkhr80000gn/T/expr14-98259a..swift:1:65:错误:使用未声明的类型“CoreLocation”
Swift.\u DebuggerSupport.stringForPrintObject(Swift.UnsafePointer(位模式:0x1290543a0)!.pointee)
corelocation是否已添加到“链接二进制文件”部分?@Priyal我现在添加了它,但仍然收到错误