I have an array of custom class [CustomClass]
. I am trying to convert it to [AnyObject]
.
self.customClassArray = self.anyObjectArray as [AnyObject]
I get the following errors:
'AnyObject' is not a subtype of 'CustomClass'
and
Cannot convert value of type '[CustomClass]' to type '[AnyObject]' in coercion.
What am I missing?
There is basically no scenario where you would have to cast your
CustomClass
toAnyObject
.Your custom class is a subtype of
AnyObject
and not the other way around, therefore any function that requires anAnyObject
will be able to handle yourCustomClass