I have added an Objective-C category to my Swift 3.0 code. It has a method with header:
+(UIBezierPath *)interpolateCGPointsWithHermite:(NSArray *)pointsAsNSValues closed:(BOOL)closed;
When I call it from my Swift code:
antiAliasing = dict.value(forKey: "antAliasing") as! NSArray
UIBezierPath.interpolateCGPoints(withHermite: antiAliasing, closed: true)
I got the error:
Cannot convert value of type 'NSArray' to expected argument type '[Any]!'
What is the problem with that ?
as?
, since it is more reliable and you won't get a crash if conversion fails.valueForKey
method.Here is the code:
if let antiAliasing = dict["antAliasing"] as? [NSValue] {
UIBezierPath.interpolateCGPoints(withHermite: antiAliasing, closed: true)
}