-2
我已經添加了Objective-C類別到我的Swift 3.0代碼。它有頭的方法:無法將'NSArray'類型的值轉換爲期望的參數類型'[Any]!'
+(UIBezierPath *)interpolateCGPointsWithHermite:(NSArray *)pointsAsNSValues closed:(BOOL)closed;
當我把它從我的銀行代碼:
antiAliasing = dict.value(forKey: "antAliasing") as! NSArray
UIBezierPath.interpolateCGPoints(withHermite: antiAliasing, closed: true)
我得到了錯誤:
Cannot convert value of type 'NSArray' to expected argument type '[Any]!'
什麼是什麼問題?
'抗鋸齒= dict.value(forKey: 「antAliasing」)作爲? NSArray ?? [ANY]'這將清除錯誤,但檢查r是否得到正確的結果 – Koushik
U需要正確打開可選值 – Koushik
從給定的參數標籤'pointsAsNSValues'我試試'as! [NSValue]'。除非你能解釋你爲什麼需要KVC,否則不要使用'valueForKey'。 – vadian