Professional Documents
Culture Documents
Programming Language
Check examples:
Any Vs AnyObject
objects array has String, Label and Date !! so the compiler will try to
get their common super class of them, it will ended by "AnyObject".
But someone can say, "55 & true are not objects ???". In fact, they are
because in runtime Swift bridged them to Foundation classes. So
String will be bridged to NSString, Int & Bools will be bridged to
NSNumber. The common superclass for them now will be NSObject
which is equivalent to AnyObject in Swift
● AnyObject is like id, you can send any message to them (call any
function), but in runtime will give error is doesn't respond to this
message. check example:
Any Vs AnyObject