Swift version: 5.10
This is one of those things that sounds obvious in retrospect: AnyObject
is Swift's way of saying, "I don't mind what type of object you pass in here, it could be a string, it could be a string, it could be a number, it could be an array, or it could be a custom type you defined yourself.
If you were wondering: the reason numbers work even though they clearly aren't objects is because Swift silently makes them objects when they need to conform to AnyObject
. Magic!
SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!
Sponsor Hacking with Swift and reach the world's largest Swift community!
Available from iOS 7.0
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Link copied to your pasteboard.