I know AnyObject can be any class type, but what I'm confused about is the declaration of AnyObject, I have read a book and some articles saying it's a protocol, but when I looked at AnyObject declaration it shows me that it is a typealias AnyObject not a protocol, and if we supposed that typealias AnyObject is assigned to some protocols (Ex: typealias AnyObject = some protocols here) I can not see what protocols the typealias AnyObject is assigned to, please help.
Swift: Confused about AnyObject declaration
159 Views Asked by Zyz At
1
There are 1 best solutions below
Related Questions in SWIFT
- Navigate after logged in with webservice
- URLSession requesting JSON array from server not working
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Protect OpenAI key using Firebase function
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Using MTLPixelFormat.rgba16Float results in random round-off errors
- Search and highlight text of current text in PDFKit Swift
- How is passing a function as a parameter related to escaping autoclosure?
- Actionable notification api call not working in background
- Custom layout occupies all horizontal space
- Is it possible to fix slow CKAsset loading on Cloudkit?
- Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value - MapView.isMyLocationEnabled
Related Questions in TYPE-ALIAS
- How can I get IDEs to recognize a desired type name for a statically declared, dynamically created class in Python?
- Creating a Public Typealias to Combine Multiple Protocols in One Swift Package/Target and Conforming to It in Other Targets
- PHPStan type aliases
- Android room dao generation fails afrer Migrating to ksp from kapt due to TypeAlias
- Why is a type alias not allowed to be a friend class name in C++?
- How do I document a type alias defined using `type` in Python?
- Why type aliases in C# cannot be used in another alias?
- Alpaca on Google colab: cannot import name 'TypeAliasType' from 'typing_extensions'
- MyPy fails with TypeAlias?
- Calling function type alias instead of function
- How to make an alias for a class that has a lot of generics (typescript)?
- How to make type alias invisible to derived classes?
- How to define a type alias (TypeAlias) that is evaluated lazily via ForwardRef in python?
- iOS App Crashes when splitting out protocol into multiple protocols and combining them using typealias
- How can I reuse "type alias" in another project?
Related Questions in ANYOBJECT
- Retrieve value from AnyObject to check against a particular constraint in Swift
- Testing type for class conformance in Swift
- how do I make a swiftui viewmodifier that accepts any object?
- Swift declaring array of multiple optional type to Any not work as expected
- Looking for a fix for Swift "ambiguous use of 'object(forKey:)'"
- Why I am getting 'valueForUndefinedKey' error when using AnyObject in Swift?
- From anyObject to array of coordinates
- Swift 5: How to test an AnyObject? variable for it's value's type?
- Why AnyObject or Any conversion is failing to GADUnifiedNativeAd in swift5?
- When is a variable a AnyObject but not a NSObject
- Why does SomeStruct() is AnyObject return true?
- swift - '(AnyObject)' is not a subtype of 'NSObject'
- Swift: Confused about AnyObject declaration
- Why casting function type as AnyObject works
- Value of type 'AnyObject' has no member 'hashValue'
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Formerly,
Swift.AnyObjectwas an empty protocol defined inPolicy.swiftand known to the compiler. On April 13, 2017, Slava Pestov changed it to the currenttypealiasand removed knowledge ofSwift.AnyObjectfrom the compiler.Currently,
Swift.AnyObjectis atypealias, declared inPolicy.swiftin the standard library source code:Builtinis a special module that contains types and functions that are built in to the compiler. Members of theBuiltinmodule don't have to be declared in Swift. Normal source code cannot access theBuiltinmodule directly. The standard library is compiled in a special compiler mode that gives it access to theBuiltinmodule.The compiler deals with the
Builtin.AnyObjecttype inswift::getBuiltinTypeinlib/AST/Builtins.cpp:So
Builtin.AnyObjectis (somewhat paradoxically) a protocol composition containing no protocols as members (that's the{}argument), and flagged as being a reference type (that's thetrueargument).What's a “protocol composition”? In Swift, you can declare that a variable's type is multiple protocols put together:
There is no way to write an empty protocol composition (a composition containing no protocols) in the Swift language.