Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda