1
我單身外景經理的職位,每當新的位置數據被內部locationManager(_:didUpdateLocations:)
檢索通知:CLLocationCoordinate2D不符合預期的字典值類型「AnyObject」
...
NSNotificationCenter.defaultCenter().postNotificationName("LocationUpdate", object: self, userInfo: ["currentLocation": currentLocation,
"currentLocationPoints": currentLocationPoints])`
...
通過上述通知發佈,我發現了以下對於userInfo
部分錯誤:
Value of type 'CLLocationCoordinate2D! does not conform to expected dictionary value type 'AnyObject'`
因此,我提出了以下類型轉換:
userInfo: ["currentLocation": currentLocation as! AnyObject,
"currentLocationPoints": currentLocationPoints as! AnyObject]
而這一次運行時,我發現了以下錯誤:
Could not cast value of type '__C.CLLocationCoordinate2D' (0xbb1f0) to 'Swift.AnyObject' (0x312d074).
爲什麼鑄造失敗?我知道Any
和AnyObject
之間的區別AnyObject
不能是一個枚舉或等,但CLLocationCoordinate2D
應該罰款鑄造。
哎呀,是我不好。感謝您指點我正確的方向。 –