gpt4 book ai didi

ios - 需要帮助声明数组以在 Swift 3 中检索 plist 信息

转载 作者:行者123 更新时间:2023-11-28 06:33:03 24 4
gpt4 key购买 nike

<分区>

由于从 Swift 2 到 Swift 3 的过渡刚刚发生的变化,我无法找出 Xcode 上我的代码问题的解决方案。

 func addBuildingPins(){
let filePath = Bundle.main.path(forResource: "CurtinBuildingList", ofType: "plist")
let buildings = NSMutableArray(contentsOfFile: (filePath)!) /*check plist file to see if it is a dictionary or array or else for loop cannot run*/
for building in buildings!{
let point = CGPointFromString(building["coordinate"] as! String)
let coordinate = CLLocationCoordinate2DMake(CLLocationDegrees(point.x), CLLocationDegrees(point.y))
let title = building["title"] as! String
let typeRawValue = Int(building["type"] as! String)!
let type = BuildingType(rawValue: typeRawValue)
let subtitle = building["subtitle"] as! String
let annotation = BuildingAnnotation(coordinate: coordinate, title: title, subtitle: subtitle, type: type!)
mapView.addAnnotation(annotation)
print(building)
}
}

错误就在方括号 (building[]) 之前。我不断收到的错误是

Type 'NSFastEnumerationIterator.Element' (aka, Any) has no subscript members".

有什么办法解决这个问题吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com