1
由于刚从Swift 2过渡到Swift 3时发生的更改,我无法找到解决我在Xcode上的代码问题的解决方案。需要帮助在Swift 3中声明plist信息检索的数组
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 [])之前。我不断收到错误是
类型“NSFastEnumerationIterator.Element”(又名有的话)没有下成员”。
有没有解决这个办法吗?
等待你也是存储数组的数组在你的plist? –
是啊,我只是FOL降低了Swift的导航功能指南,所以我的plist包含一组数组。每个次要数组都包含特定位置的信息。 – Ekwok