I have this code in Swift 1.2:
self.publicDatabase!.performQuery(query, inZoneWithID: nil) {
results, error in
if error != nil {
NotificationUtility.postNotification(Notify.CloudKitVenuesRetrieveFailed, userinfo: ["result":results, "error":error])
}
else
{
NotificationUtility.postNotification(Notify.CloudKitVenuesRetrieveSuccess, userinfo: ["result":results])
}
}
But in Swift 2.0 this yields several compiler errors:
"Type of expression is ambiguous without more context"
and
"Cannot convert value of type '[String : [CKRecord]?]' to expected argument type '[NSObject : AnyObject]?'"
I know how to fix it to make the error go away, but it seems very ugly and hacky:
self.publicDatabase!.performQuery(query, inZoneWithID: nil) {
results, error in
if error != nil {
NotificationUtility.postNotification(Notify.CloudKitVenuesRetrieveFailed, userinfo: ["result":results as! AnyObject, "error":error as! AnyObject])
}
else
{
NotificationUtility.postNotification(Notify.CloudKitVenuesRetrieveSuccess, userinfo: ["result":results as! AnyObject])
}
}
Is there a better way than having to go through every item in the dictionary and force downcast it to "AnyObject"?