I've got an error: Error: (key: AnyObject, value: AnyObject)' is not convertible to 'NSDictionary'. Help me please to fix the issue, I tried different solutions, but unsuccessfully.
func getLastDayRatesData() -> NSDictionary? {
if var rates = getRatesDataFromPlist() {
if let lastUpdated = rates["last_updated"] as? NSDate{
let ratesWithoutDate: NSMutableDictionary = rates as! NSMutableDictionary
var sortedByDateRates = sorted(ratesWithoutDate) {($0.0 as! String) > ($1.0 as! String)}
if let latestRates = sortedByDateRates.first {
return latestRates // Error: (key: AnyObject, value: AnyObject)' is not convertible to 'NSDictionary'
}
}
}
return nil
}
Just changed your code to
func getLastDayRatesData() -> (AnyObject, AnyObject)?
and everything works good.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.