Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

250
Views
How does the statement "public typealias AnyObject" make AnyObject a protocol?

When I pressed Command and clicked AnyObject to navigate to the interface of the AnyObject, I came across the below definition:

public typealias AnyObject

I see this comment written above the definition:

The protocol to which all classes implicitly conform.

Well I don't understand how this definition makes AnyObject a protocol without explicitly using the keyword protocol. Also, it's a typealias without = someType, which is an invalid statement.

I can't write a statement like:

public typealias SomeOtherObject

It gives a compilation error.

Can anyone explain what exactly is happening here?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The thing is that by pressing on AnyObject holding CMD you will not actually see source code, but just a public interface. If you will go deep into Swift source code you will actually find out that

public typealias AnyObject

is actually looks like this:

public typealias AnyObject = Builtin.AnyObject

Here is the link to file containing this code https://github.com/apple/swift/blob/master/stdlib/public/core/Policy.swift

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!