Swift中的错误:(键:AnyObject,值:AnyObject)'不能转换为&NSCictionary' NSDictionary'

时间:2015-04-23 16:36:56

标签: ios swift

我收到了错误:错误:(键:AnyObject,值:AnyObject)'不能转换为&NSCictionary'。请帮助我解决问题,我尝试了不同的解决方案,但没有成功。

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
}

1 个答案:

答案 0 :(得分:0)

刚刚将代码更改为

func getLastDayRatesData() ->  (AnyObject, AnyObject)?

一切都很好。