Dynamic type can be used for fields, variables or parameters whose concrete type is not known at compile time.
In Oxygene and C#, the
dynamic keyword can also be used to refer to this type.
Object, which is the base type of all types and where a variable typed as
Object provides the most strict access to only members known to be defined on the base
Object class itself, a variable typed as
Dynamic allows code to try and access any known (or even unknown) method or property, without any compile time checks. Only at runtime does the call get validated (and will fail, if the requested method or property does not exist).
On the Cocoa platform, the
dynamic can also be referred to as
id, and behaves identically to the
id type provided by Objective-C or the
AnyObject types provided by Apple Swift.
When using the Swift language with Elements, both
AnyObject are aliases for
Typical uses of
- Working with COM/IDispatch objects on .NET or Island/Windows.
- Working with Cocoa APIs that use