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