I've recently moved to Swift from regular objc. And yes, I know how to use Any
and AnyObject
.
But I'm curious why Apple decided on AnyObject
and Any
. Why is it good? What problem is it solving? How much developer time is it saving?
For backward compatibility with existing Cocoa libraries. Classes like NSDictionary
, NSArray
, etc. do not enforce type on all objects contained. Also in Obj-C there's id
which is a pointer to any Obj-C object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With